diff --git a/common/utils.py b/common/utils.py index fef158607652f45463928f148568693bda03a5fe..cdbb65c174398fa1f5b1df176cd9c9a534d23240 100644 --- a/common/utils.py +++ b/common/utils.py @@ -2,27 +2,25 @@ __copyright__ = "Copyright 2016-2018, Stichting SciPost (SciPost Foundation)" __license__ = "AGPL v3" -from datetime import datetime, timedelta +from datetime import timedelta from django.core.mail import EmailMultiAlternatives from django.template import loader -""" -Given two datetime parameters, this function returns the -number of complete workdays (defined as weekdays) separating them. -""" -def workdays_between (datetime_from, datetime_until): +def workdays_between(datetime_from, datetime_until): + """Return number of complete workdays. + + Given two datetime parameters, this function returns the + number of complete workdays (defined as weekdays) separating them. + """ duration = datetime_until - datetime_from - days = int(duration.total_seconds()//86400) - weeks = int(days//7) - daygenerator = (datetime_until - timedelta(x) for x in range(days - 7*weeks)) - print ('days = %s, weeks = %s' % (days, weeks)) + days = int(duration.total_seconds() // 86400) + weeks = int(days // 7) + daygenerator = (datetime_until - timedelta(x) for x in range(days - 7 * weeks)) workdays = 5 * weeks + sum(1 for day in daygenerator if day.weekday() < 5) return workdays - - class BaseMailUtil(object): mail_sender = 'no-reply@scipost.org' mail_sender_title = '' diff --git a/submissions/management/commands/send_refereeing_reminders.py b/submissions/management/commands/send_refereeing_reminders.py index bc000bba6bc62f2fb31d968581a4b797f3bbfcd6..0e98faa6cf6253a1c44f685d6e1659ae9fc3b1a5 100644 --- a/submissions/management/commands/send_refereeing_reminders.py +++ b/submissions/management/commands/send_refereeing_reminders.py @@ -13,6 +13,7 @@ from ...models import Submission class Command(BaseCommand): help = 'Sends all email reminders needed for Submissions undergoing refereeing' + def handle(self, *args, **options): for submission in Submission.objects.open_for_reporting(): # Send reminders to referees who have not responded: @@ -33,7 +34,7 @@ class Command(BaseCommand): invitation.date_last_reminded = timezone.now() invitation.save() # second (and final) reminder after 4 days - if workdays_between(invitation.date_invited, timezone.now()) == 4: + elif workdays_between(invitation.date_invited, timezone.now()) == 4: if invitation.referee: mail_sender = DirectMailUtil( mail_code='referees/invite_contributor_to_referee_reminder2', @@ -49,14 +50,13 @@ class Command(BaseCommand): invitation.save() # after 6 days of no response, EIC is automatically emailed # with the suggestion of removing and replacing this referee - if workdays_between(invitation.date_invited, timezone.now()) == 6: + elif workdays_between(invitation.date_invited, timezone.now()) == 6: mail_sender = DirectMailUtil( - mail_code='eic/referee_unresponsive', - instance=invitation) + mail_code='eic/referee_unresponsive', instance=invitation) mail_sender.send() # one week before refereeing deadline: auto email reminder to ref if workdays_between(timezone.now(), submission.reporting_deadline) == 5: for invitation in submission.refereeing_invitations.in_process(): - mail_sender = DirectMailUtil(mail_code='referees/remind_referee_deadline_1week', - instance=invitation) + mail_sender = DirectMailUtil( + mail_code='referees/remind_referee_deadline_1week', instance=invitation) mail_sender.send() diff --git a/templates/email/eic/referee_unresponsive.html b/templates/email/eic/referee_unresponsive.html index e784458f01b5c03644b815b28f59d2e536abe1b6..9dfb06aa341d18145ffcf4e5e9258dbbaa6a8d96 100644 --- a/templates/email/eic/referee_unresponsive.html +++ b/templates/email/eic/referee_unresponsive.html @@ -11,7 +11,7 @@ has failed to respond to the invitation (after being sent {{invitation.nr_reminders}} reminders). </p> <p> - Unless you are confident that this referee will really deliver a Report, and to ensure that this Submission does not suffer from unnecessary delays in processing, you should ideally invite a replacement referee using the tols on the <a href="https://scipost.org{% url 'submissions:editorial_page' assignment.submission.arxiv_identifier_w_vn_nr %}">Editorial page</a>. + Unless you are confident that this referee will really deliver a Report, and to ensure that this Submission does not suffer from unnecessary delays in processing, you should ideally invite a replacement referee using the tools on the <a href="https://scipost.org{% url 'submissions:editorial_page' invitation.submission.arxiv_identifier_w_vn_nr %}">Editorial page</a>. </p> <p> We are very grateful for your prompt action.