From 296acb9aa5dbdf6beb0f26ebbbfa163fcaa6acf4 Mon Sep 17 00:00:00 2001 From: "J.-S. Caux" <J.S.Caux@uva.nl> Date: Wed, 7 Aug 2019 10:41:46 +0200 Subject: [PATCH] Do not email Fellows with tasklist if there are no required actions --- submissions/management/commands/email_fellows_tasklist.py | 4 +++- submissions/managers.py | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/submissions/management/commands/email_fellows_tasklist.py b/submissions/management/commands/email_fellows_tasklist.py index 7425635d5..dc63441b0 100644 --- a/submissions/management/commands/email_fellows_tasklist.py +++ b/submissions/management/commands/email_fellows_tasklist.py @@ -24,9 +24,11 @@ class Command(BaseCommand): nr_potfels_to_vote_on = PotentialFellowship.objects.to_vote_on(fellow).count() recs_to_vote_on = EICRecommendation.objects.user_must_vote_on(fellow.user) assignments_ongoing = fellow.editorial_assignments.ongoing() + assignments_ongoing_with_required_actions = assignments_ongoing.with_required_actions() assignments_to_consider = fellow.editorial_assignments.invited() assignments_upcoming_deadline = assignments_ongoing.refereeing_deadline_within(days=7) - if recs_to_vote_on or assignments_ongoing or assignments_to_consider or assignments_upcoming_deadline: + if (recs_to_vote_on or assignments_ongoing_with_required_actions + or assignments_to_consider or assignments_upcoming_deadline): mail_sender = DirectMailUtil( 'fellows/email_fellow_tasklist', # Render immediately, because m2m/querysets cannot be saved for later rendering: diff --git a/submissions/managers.py b/submissions/managers.py index 8c98a7b15..47e92f277 100644 --- a/submissions/managers.py +++ b/submissions/managers.py @@ -294,6 +294,10 @@ class EditorialAssignmentQuerySet(models.QuerySet): def ongoing(self): return self.filter(status=constants.STATUS_ACCEPTED) + def with_required_actions(self): + ids = [o.id for o in self if o.submission.cycle.has_required_actions()] + return self.filter(id__in=ids) + def accepted(self): return self.filter(status__in=[constants.STATUS_ACCEPTED, constants.STATUS_COMPLETED]) -- GitLab