SciPost Code Repository

Skip to content
Snippets Groups Projects
Commit a6beabdc authored by Jorran de Wit's avatar Jorran de Wit
Browse files

Debug 1.

Found 1 typo + 1 wrong variable.
parent 602a93a5
No related branches found
No related tags found
No related merge requests found
......@@ -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 = ''
......
......@@ -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()
......@@ -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.
......
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