From ac22cd62b9f4f536c6a06014d8cb0af8a89bf38a Mon Sep 17 00:00:00 2001
From: "J.-S. Caux" <J.S.Caux@uva.nl>
Date: Thu, 31 Oct 2019 21:32:03 +0100
Subject: [PATCH] Improve decision status upon fixing

---
 submissions/forms.py                          |  8 ++
 submissions/views.py                          |  6 +-
 .../inform_authors_editorial_decision.html    | 88 +++++++++----------
 3 files changed, 55 insertions(+), 47 deletions(-)

diff --git a/submissions/forms.py b/submissions/forms.py
index 511522b06..684d9adfe 100644
--- a/submissions/forms.py
+++ b/submissions/forms.py
@@ -1446,6 +1446,14 @@ class EditorialDecisionForm(forms.ModelForm):
         self.fields['remarks_for_editorial_college'].widget.attrs.update({
             'placeholder': '[will only be seen by Fellows]'})
 
+    def clean(self):
+        cleaned_data = super().clean()
+        if (cleaned_data['decision'] == EIC_REC_REJECT and
+            cleaned_data['status'] == EditorialDecision.AWAITING_PUBOFFER_ACCEPTANCE):
+            raise forms.ValidationError(
+                'If the decision is to reject, the status cannot be '
+                'Awaiting author acceptance of publication offer.')
+
     def save(self):
         decision = super().save(commit=False)
         if not self.instance.id: # a new object is created
diff --git a/submissions/views.py b/submissions/views.py
index 17c85ad40..eb6d9c0df 100644
--- a/submissions/views.py
+++ b/submissions/views.py
@@ -2056,9 +2056,11 @@ def fix_editorial_decision(request, identifier_w_vn_nr):
     if mail_request.is_valid():
         messages.success(request, 'Authors have been emailed about the decision')
         mail_request.send_mail()
-        if decision.for_journal == submission.submitted_to:
+        if (decision.decision == EIC_REC_REJECT or
+            decision.for_journal.name == 'SciPost Selections' or
+            decision.for_journal == submission.submitted_to):
             decision.status = EditorialDecision.FIXED_AND_ACCEPTED
-        else:
+        else: # paper is accepted, but in subsidiary journal
             decision.status = EditorialDecision.AWAITING_PUBOFFER_ACCEPTANCE
         decision.save()
         submission.add_event_for_author(
diff --git a/templates/email/authors/inform_authors_editorial_decision.html b/templates/email/authors/inform_authors_editorial_decision.html
index c34184628..7a122df7f 100644
--- a/templates/email/authors/inform_authors_editorial_decision.html
+++ b/templates/email/authors/inform_authors_editorial_decision.html
@@ -7,51 +7,50 @@
 </p>
 <p>{{ decision.submission.title }}</p>
 <p>by {{ decision.submission.author_list }}.</p>
-{% if decision.for_journal.name == 'SciPost Selections' %}
-  <p>
-    We are pleased to let you know that your manuscript has been accepted for publication
-    in {{ decision.submission.submitted_to }}, with inclusion of an extended abstract
-    in SciPost Selections.
-  </p>
-  <p>
-    We warmly congratulate you on this achievement, which represents the highest mark of
-    recognition given by the Editorial College.
-  </p>
-  <p>
-    Your manuscript will now be taken charge of by our production team,
-    which will soon send you proofs to check before final publication.
-  </p>
-{% else %}
-  {% if decision.publish %}
-    {% if decision.for_journal == decision.submission.submitted_to %}
-      <p>
-	We are pleased to let you know that your manuscript has been accepted for publication
-	in {{ decision.submission.submitted_to }}.
-      </p>
-      <p>
-	Your manuscript will now be taken charge of by our production team,
-	which will soon send you proofs to check before final publication.
-      </p>
-    {% else %}
-      <p>
-	We would like to offer you publication of your manuscript in
-	{{ decision.for_journal }} (you had originally submitted
-	to {{ decision.submission.submitted_to }}).
-      </p>
-      <p>
-	You can inform us of choice by going to your personal page: under
-	the Submissions tab, you will find links to accept this offer or
-	to turn it down (you will also find these links on the submission page of this manuscript).
-	<strong>We will await your confirmation of acceptance of this publication offer
-	  before initiating production of the proofs of your paper.</strong>
-      </p>
-      <p>
-	If you decide to turn this offer down, you can simply withdraw your manuscript.
-	It will then not be considered for further processing on our side
-	and you will be free to submit it elsewhere.
-      </p>
-    {% endif %}
+{% if decision.publish %}
+  {% if decision.for_journal.name == 'SciPost Selections' %}
+    <p>
+      We are pleased to let you know that your manuscript has been accepted for publication
+      in {{ decision.submission.submitted_to }}, with inclusion of an extended abstract
+      in SciPost Selections.
+    </p>
+    <p>
+      We warmly congratulate you on this achievement, which represents the highest mark of
+      recognition given by the Editorial College.
+    </p>
+    <p>
+      Your manuscript will now be taken charge of by our production team,
+      which will soon send you proofs to check before final publication.
+    </p>
+  {% elif decision.for_journal == decision.submission.submitted_to %}
+    <p>
+      We are pleased to let you know that your manuscript has been accepted for publication
+      in {{ decision.submission.submitted_to }}.
+    </p>
+    <p>
+      Your manuscript will now be taken charge of by our production team,
+      which will soon send you proofs to check before final publication.
+    </p>
   {% else %}
+    <p>
+      We would like to offer you publication of your manuscript in
+      {{ decision.for_journal }} (you had originally submitted
+      to {{ decision.submission.submitted_to }}).
+    </p>
+    <p>
+      You can inform us of choice by going to your personal page: under
+      the Submissions tab, you will find links to accept this offer or
+      to turn it down (you will also find these links on the submission page of this manuscript).
+      <strong>We will await your confirmation of acceptance of this publication offer
+	before initiating production of the proofs of your paper.</strong>
+    </p>
+    <p>
+      If you decide to turn this offer down, you can simply withdraw your manuscript.
+      It will then not be considered for further processing on our side
+      and you will be free to submit it elsewhere.
+    </p>
+  {% endif %}
+{% else %}
     <p>
       We are sorry to inform you that your Submission has not been accepted for publication.
     </p>
@@ -68,7 +67,6 @@
       This completes the editorial procedure on our side, and you are now free to submit
       your manuscript elsewhere.
     </p>
-  {% endif %}
 {% endif %}
 {% if decision.remarks_for_authors %}
   <p><strong>Further remarks from Editorial Administration:</strong></p>
-- 
GitLab