Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Close incomplete review assignments when an article is rejected #4305

Merged
merged 3 commits into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions src/review/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
9 changes: 9 additions & 0 deletions src/submission/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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())

Expand Down
13 changes: 13 additions & 0 deletions src/templates/admin/review/decision.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,19 @@ <h2>Article Decision</h2>
</div>
{% endif %}
{% endif %}
{% if decision == 'decline' and article.incomplete_reviews.count > 0 %}
<p>The following incomplete reviews will be marked as withdrawn:</p>
{% for review in article.incomplete_reviews %}
<div class="bs-callout bs-callout-warning">
<h4>{{ review.reviewer.full_name }} (Round {{ review.review_round.round_number }})</h4>
<p>This review was assigned
on {{ review.date_requested }} and was due
on {{ review.date_due }}</p>
<p>{% 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 %}</p>
</div>
<br />
{% endfor %}
{% endif %}
{% if article.hidden_completed_reviews %}
<div class="bs-callout bs-callout-danger">
<p>{% trans 'Note: This article has completed reviews that have not been made available to the author:' %}</p>
Expand Down