SciPost Code Repository

Skip to content
Snippets Groups Projects
Commit 764af1a6 authored by Jean-Sébastien Caux's avatar Jean-Sébastien Caux
Browse files

Update email_fellows_tasklist management command

parent 209cb147
No related branches found
No related tags found
No related merge requests found
...@@ -53,10 +53,6 @@ class ContributorQuerySet(models.QuerySet): ...@@ -53,10 +53,6 @@ class ContributorQuerySet(models.QuerySet):
return self.filter(user__is_active=True, status=NEWLY_REGISTERED return self.filter(user__is_active=True, status=NEWLY_REGISTERED
).exclude(status=DOUBLE_ACCOUNT) ).exclude(status=DOUBLE_ACCOUNT)
def fellows(self):
"""TODO: NEEDS UPDATE TO NEW FELLOWSHIP RELATIONS."""
return self.filter(fellowships__isnull=False).distinct()
def with_duplicate_names(self): def with_duplicate_names(self):
""" """
Returns only potential duplicate Contributors (as identified by first and Returns only potential duplicate Contributors (as identified by first and
......
...@@ -8,7 +8,7 @@ from ...models import EICRecommendation ...@@ -8,7 +8,7 @@ from ...models import EICRecommendation
from colleges.models import PotentialFellowship from colleges.models import PotentialFellowship
from mails.utils import DirectMailUtil from mails.utils import DirectMailUtil
from scipost.models import Contributor from colleges.models import Fellowship
class Command(BaseCommand): class Command(BaseCommand):
...@@ -17,15 +17,15 @@ class Command(BaseCommand): ...@@ -17,15 +17,15 @@ class Command(BaseCommand):
help = 'Sends an email to Fellows with current and upcoming tasks list' help = 'Sends an email to Fellows with current and upcoming tasks list'
def handle(self, *args, **kwargs): def handle(self, *args, **kwargs):
fellows = Contributor.objects.fellows() fellowships = Fellowship.objects.active()
count = 0 count = 0
for fellow in fellows: for fellowship in fellowships:
nr_potfels_to_vote_on = PotentialFellowship.objects.to_vote_on(fellow).count() nr_potfels_to_vote_on = PotentialFellowship.objects.to_vote_on(fellowship.contributor).count()
recs_to_vote_on = EICRecommendation.objects.user_must_vote_on(fellow.user) recs_to_vote_on = EICRecommendation.objects.user_must_vote_on(fellowship.contributor.user)
assignments_ongoing = fellow.editorial_assignments.ongoing() assignments_ongoing = fellowship.contributor.editorial_assignments.ongoing()
assignments_ongoing_with_required_actions = assignments_ongoing.with_required_actions() assignments_ongoing_with_required_actions = assignments_ongoing.with_required_actions()
assignments_to_consider = fellow.editorial_assignments.invited() assignments_to_consider = fellowship.contributor.editorial_assignments.invited()
assignments_upcoming_deadline = assignments_ongoing.refereeing_deadline_within(days=7) assignments_upcoming_deadline = assignments_ongoing.refereeing_deadline_within(days=7)
if (recs_to_vote_on or assignments_ongoing_with_required_actions if (recs_to_vote_on or assignments_ongoing_with_required_actions
or assignments_to_consider or assignments_upcoming_deadline): or assignments_to_consider or assignments_upcoming_deadline):
...@@ -33,8 +33,8 @@ class Command(BaseCommand): ...@@ -33,8 +33,8 @@ class Command(BaseCommand):
'fellows/email_fellow_tasklist', 'fellows/email_fellow_tasklist',
# Render immediately, because m2m/querysets cannot be saved for later rendering: # Render immediately, because m2m/querysets cannot be saved for later rendering:
delayed_processing=False, delayed_processing=False,
object=fellow, object=fellowship.contributor,
fellow=fellow, fellow=fellowship.contributor,
nr_potfels_to_vote_on=nr_potfels_to_vote_on, nr_potfels_to_vote_on=nr_potfels_to_vote_on,
recs_to_vote_on=recs_to_vote_on, recs_to_vote_on=recs_to_vote_on,
assignments_ongoing=assignments_ongoing, assignments_ongoing=assignments_ongoing,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment