diff --git a/src/review/tests.py b/src/review/tests.py index da1956ef1..a7ae5cf7c 100644 --- a/src/review/tests.py +++ b/src/review/tests.py @@ -275,6 +275,50 @@ def test_csv_doesnt_create_duplicate_assignments(self): self.review_assignment_complete, ) + def test_incomplete_reviews(self): + args = {'owner': self.regular_user, + 'title': 'Test Article', + 'stage': submission_models.STAGE_UNDER_REVIEW,} + article1 = helpers.create_article(self.journal_one, **args) + + article1.correspondence_author = self.regular_user + article1.save() + + round = review_models.ReviewRound.objects.create(article=article1, + round_number=1,) + + assignment = helpers.create_review_assignment( + journal=self.journal_one, + article=article1, + is_complete=False, + review_round=round, + reviewer=self.regular_user, + ) + assignment.decision = None + assignment.save() + + self.client.force_login(self.editor) + decline_url = reverse('review_decision', + kwargs={'article_id': article1.pk, + 'decision': 'decline'}) + response = self.client.get(decline_url, + SERVER_NAME=self.journal_one.domain,) + msg = "The following incomplete reviews will be marked as withdrawn" + self.assertContains(response, msg) + + data = {'cc': [''], + 'bcc': [''], + 'subject': ['Article Declined'], + 'body': ['Article Declined'], + 'attachments': [''], + 'skip': ['skip']} + response = self.client.post(decline_url, + data, + SERVER_NAME=self.journal_one.domain,) + review_set = article1.reviewassignment_set.all() + self.assertEqual(review_set.filter(is_complete=True).count(), 1) + self.assertEqual(review_set.filter(is_complete=False).count(), 0) + def test_completed_reviews_shared_setting(self): # setup data article_with_completed_reviews = helpers.create_article( diff --git a/src/submission/models.py b/src/submission/models.py index 086ca7511..b845b5d71 100755 --- a/src/submission/models.py +++ b/src/submission/models.py @@ -1514,6 +1514,10 @@ def decline_article(self): self.date_declined = timezone.now() self.date_accepted = None self.stage = STAGE_REJECTED + + self.incomplete_reviews().update(decision=RD.DECISION_WITHDRAWN.value, + date_complete=timezone.now(), + is_complete=True,) self.save() def undo_review_decision(self): @@ -1831,6 +1835,11 @@ def hidden_completed_reviews(self): decision='withdrawn', ) + def incomplete_reviews(self): + return self.reviewassignment_set.filter(is_complete=False, + date_declined__isnull=True, + decision__isnull=True) + def ms_and_figure_files(self): return chain(self.manuscript_files.all(), self.data_figure_files.all()) diff --git a/src/templates/admin/review/decision.html b/src/templates/admin/review/decision.html index dc9acfd86..22e2c39ca 100644 --- a/src/templates/admin/review/decision.html +++ b/src/templates/admin/review/decision.html @@ -39,6 +39,19 @@
The following incomplete reviews will be marked as withdrawn:
+ {% for review in article.incomplete_reviews %} +This review was assigned + on {{ review.date_requested }} and was due + on {{ review.date_due }}
+{% if review.date_accepted %}The reviewer agreed to do this review on {{ review.date_accepted }}.{% else %}The reviewer has not agreed to complete this review.{% endif %}
+{% trans 'Note: This article has completed reviews that have not been made available to the author:' %}