From 18f31a1ba1cf53756c9c10d2b413add5f5e02b8e Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Mon, 9 Sep 2024 18:48:51 +0200 Subject: [PATCH 1/3] Use setting to get submit_info form --- src/submission/forms.py | 14 ++++++++++++++ src/submission/views.py | 5 +---- src/utils/install/submission_items.json | 10 ++++++++++ 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/submission/forms.py b/src/submission/forms.py index 6778cc00c3..80cbe6947b 100755 --- a/src/submission/forms.py +++ b/src/submission/forms.py @@ -6,6 +6,7 @@ import re from django import forms +from django.utils.module_loading import import_string from django.utils.translation import gettext, gettext_lazy as _ from submission import models @@ -22,6 +23,19 @@ from tinymce.widgets import TinyMCE +def get_submit_info_form(request): + if request.user.is_editor(request): + custom_form = setting_handler.get_setting( + "general", "submit_info_form_editor_version", request.journal + ) + else: + custom_form = setting_handler.get_setting( + "general", "submit_info_form_general_version", request.journal + ) + form_path = custom_form.processed_value + return import_string(form_path) + + class PublisherNoteForm(forms.ModelForm): class Meta: diff --git a/src/submission/views.py b/src/submission/views.py index cd2fa76161..c64e25e876 100755 --- a/src/submission/views.py +++ b/src/submission/views.py @@ -185,10 +185,7 @@ def submit_info(request, article_id): request.journal, ).processed_value - # Determine the form to use depending on whether the user is an editor. - article_info_form = forms.ArticleInfoSubmit - if request.user.is_editor(request): - article_info_form = forms.EditorArticleInfoSubmit + article_info_form = forms.get_submit_info_form(request) form = article_info_form( instance=article, diff --git a/src/utils/install/submission_items.json b/src/utils/install/submission_items.json index d857fa13c0..16ee064e8a 100644 --- a/src/utils/install/submission_items.json +++ b/src/utils/install/submission_items.json @@ -43,5 +43,15 @@ "group": "special", "name": "sections", "title": "sections" + }, + { + "group": "general", + "name": "submit_info_form_editor_version", + "title": "submission.forms.EditorArticleInfoSubmit" + }, + { + "group": "general", + "name": "submit_info_form_general_version", + "title": "submission.forms.ArticleInfoSubmit" } ] \ No newline at end of file From 68af9400e35fdd29169fa247f1e64e47354057af Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Mon, 9 Sep 2024 19:04:43 +0200 Subject: [PATCH 2/3] More ArticleInfoForm replacements --- src/submission/forms.py | 9 +++++++++ src/submission/views.py | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/submission/forms.py b/src/submission/forms.py index 80cbe6947b..b817af8ca6 100755 --- a/src/submission/forms.py +++ b/src/submission/forms.py @@ -36,6 +36,15 @@ def get_submit_info_form(request): return import_string(form_path) + +def get_submit_info_edit_form(request): + custom_form = setting_handler.get_setting( + "general", "submit_info_form_general_version", request.journal + ) + form_path = custom_form.processed_value + return import_string(form_path) + + class PublisherNoteForm(forms.ModelForm): class Meta: diff --git a/src/submission/views.py b/src/submission/views.py index c64e25e876..966ce579b0 100755 --- a/src/submission/views.py +++ b/src/submission/views.py @@ -730,7 +730,7 @@ def edit_metadata(request, article_id): article=article, ) - info_form = forms.ArticleInfo( + info_form = forms.get_submit_info_edit_form(request)( instance=article, additional_fields=additional_fields, submission_summary=submission_summary, @@ -764,7 +764,7 @@ def edit_metadata(request, article_id): return redirect(reverse_url) if 'metadata' in request.POST: - info_form = forms.ArticleInfo( + info_form = forms.get_submit_info_edit_form(request)( request.POST, instance=article, additional_fields=additional_fields, From a07b0c86ac24547729b3d4aca1172e9891a55bdc Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Wed, 11 Sep 2024 00:44:30 +0200 Subject: [PATCH 3/3] Add settings to defaults list --- src/utils/install/journal_defaults.json | 38 +++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/utils/install/journal_defaults.json b/src/utils/install/journal_defaults.json index 4475d5ffd9..668d913ba1 100644 --- a/src/utils/install/journal_defaults.json +++ b/src/utils/install/journal_defaults.json @@ -5117,5 +5117,43 @@ "value": { "default": "" } + }, + { + "group": { + "name": "general" + }, + "setting": { + "description": "Dotted path of the form used during the submission phase for editors.", + "is_translatable": true, + "name": "submit_info_form_editor_version", + "pretty_name": "General Publication Editor info form", + "type": "char" + }, + "value": { + "default": "submission.forms.EditorArticleInfoSubmit" + }, + "editable_by": [ + "editor", + "journal-manager" + ] + }, + { + "group": { + "name": "general" + }, + "setting": { + "description": "Dotted path of the form used during the submission phase for authors.", + "is_translatable": true, + "name": "submit_info_form_general_version", + "pretty_name": "General Publication info form", + "type": "char" + }, + "value": { + "default": "submission.forms.ArticleInfoSubmit" + }, + "editable_by": [ + "editor", + "journal-manager" + ] } ]