From d2667ea177a15dbb777e4e6750f60447a93bc3a9 Mon Sep 17 00:00:00 2001 From: George Katsikas <giorgakis.katsikas@gmail.com> Date: Wed, 14 Aug 2024 13:37:33 +0200 Subject: [PATCH] limit required actions for past submissions --- .../submissions/models/submission.py | 2 +- .../submissions/refereeing_cycles.py | 29 ++++++++++++------- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/scipost_django/submissions/models/submission.py b/scipost_django/submissions/models/submission.py index ba6d6c197..e21d69ac5 100644 --- a/scipost_django/submissions/models/submission.py +++ b/scipost_django/submissions/models/submission.py @@ -582,7 +582,7 @@ class Submission(models.Model): @property def is_latest(self): - return self.status != self.RESUBMITTED + return self == self.get_latest_version() @property def authors_as_list(self): diff --git a/scipost_django/submissions/refereeing_cycles.py b/scipost_django/submissions/refereeing_cycles.py index f41a124f5..6a630c7d0 100644 --- a/scipost_django/submissions/refereeing_cycles.py +++ b/scipost_django/submissions/refereeing_cycles.py @@ -12,6 +12,11 @@ from common.utils import get_current_domain from . import constants +from typing import TYPE_CHECKING + +if TYPE_CHECKING: + from submissions.models.submission import Submission + @html_safe class RequiredActionsDict(dict): @@ -243,7 +248,7 @@ class BaseCycle: days_for_refereeing = 28 can_invite_referees = True - def __init__(self, submission): + def __init__(self, submission: "Submission"): self._submission = submission self._required_actions = None @@ -274,6 +279,19 @@ class BaseCycle: """Gather the required actions list and populate self._required_actions.""" self._required_actions = RequiredActionsDict() + # Comments requiring vetting (including replies and recursive comments) + comments_to_vet = self._submission.comments_set_complete().awaiting_vetting() + for comment in comments_to_vet: + self.add_action(VettingAction(comment)) + + reports_to_vet = self._submission.reports.awaiting_vetting() + for report in reports_to_vet: + self.add_action(VettingAction(report)) + + # If this cycle is not the latest one in the thread, return early, skipping other actions + if not self._submission.is_latest: + return + if not self._submission.refereeing_cycle: # Submission is a resubmission: EIC has to determine which cycle to proceed with. self.add_action(CycleChoiceAction()) @@ -288,15 +306,6 @@ class BaseCycle: ) self.add_action(action) - # Comments requiring vetting (including replies and recursive comments) - comments_to_vet = self._submission.comments_set_complete().awaiting_vetting() - for comment in comments_to_vet: - self.add_action(VettingAction(comment)) - - reports_to_vet = self._submission.reports.awaiting_vetting() - for report in reports_to_vet: - self.add_action(VettingAction(report)) - if self.can_invite_referees and self._submission.in_stage_in_refereeing: # Referees required in this cycle. referee_invitations_count = ( -- GitLab