diff --git a/forms.py b/forms.py
index 2ad631f..0bb68f1 100644
--- a/forms.py
+++ b/forms.py
@@ -1,16 +1,33 @@
from django import forms
+from django_summernote.widgets import SummernoteWidget
+
+
class ArchiveAdminForm(forms.Form):
- journal_archive_enabled = forms.BooleanField(required=False,
- label='Journal Archiving',
- help_text='Turn on or off automatic archiving of articles in this journal, and link to journal archives from browse page.')
- article_archive_enabled = forms.BooleanField(required=False,
- label='Article Archiving',
- help_text='Turn on or off link when viewing articles to see their version history.')
- edit_article_enabled = forms.BooleanField(required=False,
- label='Article Editing',
- help_text='Toggle button for authors to update a published article they submitted, and for editors to request that a published article be updated.')
- request_email_template = forms.CharField(required=True, max_length=500,
- label='Email template',
- help_text='Template for email sent to author when an editor requests an update.',
- widget=forms.Textarea)
\ No newline at end of file
+ journal_archive_enabled = forms.BooleanField(
+ required=False,
+ label='Journal Archiving',
+ help_text='Turn on or off automatic archiving of articles in '
+ 'this journal, and link to journal archives from browse page.',
+ )
+ article_archive_enabled = forms.BooleanField(
+ required=False,
+ label='Article Archiving',
+ help_text='Turn on or off link when viewing articles to see '
+ 'their version history.',
+ )
+ edit_article_enabled = forms.BooleanField(
+ required=False,
+ label='Article Editing',
+ help_text='Toggle button for authors to update a published '
+ 'article they submitted, and for editors to request '
+ 'that a published article be updated.',
+ )
+ request_email_template = forms.CharField(
+ required=True,
+ max_length=500,
+ label='Email template',
+ help_text='Template for email sent to author when an editor '
+ 'requests an update.',
+ widget=SummernoteWidget(),
+ )
diff --git a/install/settings.json b/install/settings.json
new file mode 100644
index 0000000..7c990ed
--- /dev/null
+++ b/install/settings.json
@@ -0,0 +1,62 @@
+[
+ {
+ "group": {
+ "name": "plugin:archive_plugin"
+ },
+ "setting": {
+ "description": "Enable Journal Archive Display.",
+ "is_translatable": false,
+ "name": "journal_archive_enabled",
+ "pretty_name": "Enable Journal Archive Display",
+ "type": "boolean"
+ },
+ "value": {
+ "default": false
+ }
+ },
+ {
+ "group": {
+ "name": "plugin:archive_plugin"
+ },
+ "setting": {
+ "description": "Enable Article Archive Display.",
+ "is_translatable": false,
+ "name": "article_archive_enabled",
+ "pretty_name": "Enable Article Archive Display",
+ "type": "boolean"
+ },
+ "value": {
+ "default": false
+ }
+ },
+ {
+ "group": {
+ "name": "plugin:archive_plugin"
+ },
+ "setting": {
+ "description": "Enable Article Editing and Updating.",
+ "is_translatable": false,
+ "name": "edit_article_enabled",
+ "pretty_name": "Enable Article Editing and Updating",
+ "type": "boolean"
+ },
+ "value": {
+ "default": false
+ }
+ },
+ {
+ "group": {
+ "name": "plugin:archive_plugin"
+ },
+ "setting": {
+ "description": "Template for the email sent to authors when an editor requests an article be updated'.",
+ "is_translatable": true,
+ "name": "request_email_template",
+ "pretty_name": "Request Email Template",
+ "type": "rich-text"
+ },
+ "value": {
+ "default": "
Dear {{ article.correspondence_author.full_name }},
The editorial board of {{ article.journal.name }} requests that the article, '{{ article.title }},' be updated. Please follow the link below to begin the submission process.
Submit your update.
Best,
Editorial Board, {{ article.journal.code }}
"
+ }
+ }
+]
\ No newline at end of file
diff --git a/plugin_settings.py b/plugin_settings.py
index 19ff4d4..6d7206a 100644
--- a/plugin_settings.py
+++ b/plugin_settings.py
@@ -2,11 +2,12 @@
DESCRIPTION = 'A plugin for managing archives of previous version of articles'
AUTHOR = 'Drew Stimson and Daniel Evans'
VERSION = '0.1'
+
SHORT_NAME = 'archive_plugin'
MANAGER_URL = 'archive_index'
-from utils import models, setting_handler
-from journal.models import Journal
+from utils import plugins
+from utils.install import update_settings
from events import logic as event_logic
from plugins.archive_plugin.events import register_update_time
@@ -14,43 +15,26 @@
event_logic.Events.register_for_event(event_logic.Events.ON_AUTHOR_PUBLICATION, register_update_time)
-def install():
- new_plugin, created = models.Plugin.objects.get_or_create(name=SHORT_NAME, version=VERSION, enabled=True)
+class ArchivePlugin(plugins.Plugin):
+ plugin_name = PLUGIN_NAME
+ display_name = PLUGIN_NAME
+ description = DESCRIPTION
+ author = AUTHOR
+ short_name = SHORT_NAME
- if created:
- print('Plugin {0} installed.'.format(PLUGIN_NAME))
- else:
- print('Plugin {0} is already installed.'.format(PLUGIN_NAME))
+ manager_url = MANAGER_URL
- models.PluginSetting.objects.get_or_create(name='journal_archive_enabled', plugin=new_plugin, types='boolean',
- pretty_name='Enable Journal Archive Display',
- description='Enable Journal Archive Display',
- is_translatable=False)
- models.PluginSetting.objects.get_or_create(name='article_archive_enabled', plugin=new_plugin, types='boolean',
- pretty_name='Enable Article Archive Display',
- description='Enable Article Archive Diesplay',
- is_translatable=False)
- models.PluginSetting.objects.get_or_create(name='edit_article_enabled', plugin=new_plugin, types='boolean',
- pretty_name='Enable Article Editing and Updating',
- description='Enable Article Editing and Updating',
- is_translatable=False)
- models.PluginSetting.objects.get_or_create(name='request_email_template', plugin=new_plugin, types='rich-text',
- pretty_name='Request Email Template',
- description='Template for the email sent to authors '
- 'when an editor requests an article be updated',
- is_translatable=False)
+ version = VERSION
+ janeway_version = "1.4.0"
- message_text = """
- Dear {{ article.correspondence_author.full_name }},
- The editorial board of {{ article.journal.name }} requests that the article, '{{ article.title }},' be updated. Please follow the link below to begin the submission process.
- Submit your update.
- Best,
Editorial Board, {{ article.journal.code }}
- """
+ is_workflow_plugin = False
- # set starting message template for each journal
- for journal in Journal.objects.all():
- setting_handler.save_plugin_setting(new_plugin, 'request_email_template', message_text, journal)
- # TODO: make archive interval a setting
+
+def install():
+ ArchivePlugin.install()
+ update_settings(
+ file_path='plugins/archive_plugin/install/settings.json'
+ )
def hook_registry():
diff --git a/views.py b/views.py
index 53f58e4..e34e180 100644
--- a/views.py
+++ b/views.py
@@ -7,32 +7,42 @@
from plugins.archive_plugin.models import Version
from utils import setting_handler, models
-from utils.notify_helpers import send_email_with_body_from_user
from security.decorators import editor_user_required, author_user_required
from submission.models import Article
from journal.models import Issue
+
@editor_user_required
def index(request):
"""
Creates the admin page for turning the plugin's elements on or off
"""
plugin = models.Plugin.objects.get(name=plugin_settings.SHORT_NAME)
-
- journal_archive_enabled = setting_handler.get_plugin_setting(plugin, 'journal_archive_enabled', request.journal, create=True,
- pretty='Enable Journal Archive Display', types='boolean').processed_value
- article_archive_enabled = setting_handler.get_plugin_setting(plugin, 'article_archive_enabled', request.journal, create=True,
- pretty='Enable Article Archive Display', types='boolean').processed_value
- edit_article_enabled = setting_handler.get_plugin_setting(plugin, 'edit_archive_enabled', request.journal, create=True,
- pretty='Enable Article Editing and Updating', types='boolean').processed_value
- request_template = setting_handler.get_plugin_setting(plugin, 'request_email_template', request.journal, create=True,
- pretty='Request Email Template', types='rich-text').processed_value
-
- admin_form = forms.ArchiveAdminForm(initial={'journal_archive_enabled': journal_archive_enabled,
- 'article_archive_enabled': article_archive_enabled,
- 'edit_article_enabled': edit_article_enabled,
- 'request_email_template': request_template})
+
+ journal_archive_enabled = setting_handler.get_plugin_setting(plugin,
+ 'journal_archive_enabled', request.journal,
+ create=True,
+ pretty='Enable Journal Archive Display',
+ types='boolean',
+ ).processed_value
+ article_archive_enabled = setting_handler.get_plugin_setting(plugin, 'article_archive_enabled', request.journal,
+ create=True,
+ pretty='Enable Article Archive Display',
+ types='boolean').processed_value
+ edit_article_enabled = setting_handler.get_plugin_setting(plugin, 'edit_article_enabled', request.journal,
+ create=True,
+ pretty='Enable Article Editing and Updating',
+ types='boolean').processed_value
+ request_template = setting_handler.get_plugin_setting(plugin, 'request_email_template', request.journal,
+ create=True,
+ pretty='Request Email Template',
+ types='rich-text').processed_value
+
+ admin_form = forms.ArchiveAdminForm(initial={'journal_archive_enabled': journal_archive_enabled,
+ 'article_archive_enabled': article_archive_enabled,
+ 'edit_article_enabled': edit_article_enabled,
+ 'request_email_template': request_template})
if request.POST:
admin_form = forms.ArchiveAdminForm(request.POST)
@@ -80,11 +90,13 @@ def article_archive(request, article_id):
base_article = article
# get queryset of all articles with same base_article (including original base article)
- versions = Article.objects.filter(Q(version__base_article=base_article) | Q(pk=base_article.pk)).filter(stage='Published').order_by('-date_published')
+ versions = Article.objects.filter(Q(version__base_article=base_article) | Q(pk=base_article.pk)).filter(
+ stage='Published').order_by('-date_published')
# prepare and return page
-
- context = {'base_article': base_article, 'orig_article': article, 'versions': versions, 'journal': request.journal}
+
+ context = {'base_article': base_article, 'orig_article': article, 'versions': versions,
+ 'journal': request.journal}
# if no updates, just return the single entry
else:
@@ -101,10 +113,10 @@ def update_article_prompt(request, article_id):
: article_id is the pk of the article
"""
article = get_object_or_404(Article, pk=article_id)
-
+
template = 'archive_plugin/inject_edit_article_selector.html'
context = {'article': article}
-
+
return render(request, template, context)
@@ -116,13 +128,14 @@ def update_article(request, article_id):
: base_article is the pk of the original article this is updating
The relationship between multiple articles is traced via publication dates
"""
- if request.POST: # a gift for Andy
+ if request.POST: # a gift for Andy
update_type = request.POST.get('update_type')
parent_article = get_object_or_404(Article, pk=article_id)
new_article = logic.copy_article_for_update(parent_article.pk)
base_article = logic.get_base_article(parent_article.pk)
- new_version = Version(article=new_article, parent_article=parent_article, update_type=update_type, base_article=base_article)
+ new_version = Version(article=new_article, parent_article=parent_article, update_type=update_type,
+ base_article=base_article)
new_version.save()
return redirect(reverse('submit_info', kwargs={'article_id': new_article.pk}))
@@ -134,7 +147,7 @@ def request_update(request, article_id):
Processes request from editor to have an entry updated, sends email to registered article owner with update request.
article_id is pk of the article to be updated
"""
-
+
article = get_object_or_404(Article, pk=article_id)
transactional_emails.send_update_request_email(request, article)
@@ -165,4 +178,4 @@ def browse_entries(request):
context = {"articles": final_articles}
template = "archive_plugin/browse.html"
- return render(request, template, context)
\ No newline at end of file
+ return render(request, template, context)