From d2c7b8f916420beb8817c2d3dddaada517351bb9 Mon Sep 17 00:00:00 2001 From: "J.-S. Caux" <J.S.Caux@uva.nl> Date: Thu, 26 Apr 2018 01:15:23 +0200 Subject: [PATCH] First take on auto emails (single method for all ref reminders) --- .../commands/send_refereeing_reminders.py | 44 +++++++++++++++++++ submissions/managers.py | 8 ++-- submissions/views.py | 1 - ...vite_contributor_to_referee_reminder1.html | 29 ++++++++++++ ...vite_contributor_to_referee_reminder1.json | 8 ++++ ...ite_unregistered_to_referee_reminder1.html | 34 ++++++++++++++ ...ite_unregistered_to_referee_reminder1.json | 8 ++++ .../remind_referee_deadline_1week.html | 16 +++++++ .../remind_referee_deadline_1week.json | 8 ++++ 9 files changed, 151 insertions(+), 5 deletions(-) create mode 100644 submissions/management/commands/send_refereeing_reminders.py create mode 100644 templates/email/referees/invite_contributor_to_referee_reminder1.html create mode 100644 templates/email/referees/invite_contributor_to_referee_reminder1.json create mode 100644 templates/email/referees/invite_unregistered_to_referee_reminder1.html create mode 100644 templates/email/referees/invite_unregistered_to_referee_reminder1.json create mode 100644 templates/email/referees/remind_referee_deadline_1week.html create mode 100644 templates/email/referees/remind_referee_deadline_1week.json diff --git a/submissions/management/commands/send_refereeing_reminders.py b/submissions/management/commands/send_refereeing_reminders.py new file mode 100644 index 000000000..ea0039307 --- /dev/null +++ b/submissions/management/commands/send_refereeing_reminders.py @@ -0,0 +1,44 @@ +__copyright__ = "Copyright 2016-2018, Stichting SciPost (SciPost Foundation)" +__license__ = "AGPL v3" + + +from django.core.management.base import BaseCommand +from django.utils import timezone + +from mails.utils import DirectMailUtil + +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(): + # fewer than 3 referees invited within 48 hours? EIC must take action + # TODO + # 3 days after ref invite sent out, upon no response from referee: first auto reminder + for invitation in submission.referee_invitations.pending(): + if (timezone.now() > invitation.date_invited + timezone.timedelta(days=2) + and timezone.now() < invitation.date_invited + timezone.timedelta(days=3)): + if invitation.referee: + mail_sender = DirectMailUtil( + mail_code='referees/invite_contributor_to_referee_reminder1', + instance=invitation) + mail_sender.send() + else: + mail_sender = DirectMailUtil( + mail_code='referees/invite_unregistered_to_referee_reminder1', + instance=invitation) + mail_sender.send() + # second and final reminder after 6 days + # TODO + # after 8 days of no response, EIC is automatically emailed + # with the suggestion of removing and replacing this referee + # TODO + # one week before refereeing deadline: auto email reminder to ref + if (submission.reporting_deadline > timezone.now() + timezone.timedelta(days=7) + and submission.reporting_deadline < timezone.now() + timezone.timedelta(days=8)): + for invitation in submission.refereeing_invitations.in_process(): + mail_sender = DirectMailUtil(mail_code='referees/remind_referee_deadline_1week', + instance=invitation) + mail_sender.send() diff --git a/submissions/managers.py b/submissions/managers.py index ff3e92c92..a639e9e5d 100644 --- a/submissions/managers.py +++ b/submissions/managers.py @@ -202,7 +202,7 @@ class SubmissionQuerySet(models.QuerySet): def open_for_reporting(self): """ - Return Submissions that have appriopriate status for reporting. + Return Submissions that have appropriate status for reporting. The `open_for_reporting` property is not filtered as some invited visitors still need to have access. """ @@ -358,11 +358,11 @@ class RefereeInvitationQuerySet(models.QuerySet): def in_process(self): return self.accepted().filter(fulfilled=False) - def approaching_deadline(self): + def approaching_deadline(self, days=2): qs = self.in_process() - psuedo_deadline = now + datetime.timedelta(days=2) + pseudo_deadline = now + datetime.timedelta(days) deadline = datetime.datetime.now() - qs = qs.filter(submission__reporting_deadline__lte=psuedo_deadline, + qs = qs.filter(submission__reporting_deadline__lte=pseudo_deadline, submission__reporting_deadline__gte=deadline) return qs diff --git a/submissions/views.py b/submissions/views.py index 2903c0c04..6f7122abc 100644 --- a/submissions/views.py +++ b/submissions/views.py @@ -863,7 +863,6 @@ def ref_invitation_reminder(request, arxiv_identifier_w_vn_nr, invitation_id): invitation.nr_reminders += 1 invitation.date_last_reminded = timezone.now() invitation.save() - SubmissionUtils.load({'invitation': invitation}) if invitation.referee is not None: SubmissionUtils.send_ref_reminder_email() else: diff --git a/templates/email/referees/invite_contributor_to_referee_reminder1.html b/templates/email/referees/invite_contributor_to_referee_reminder1.html new file mode 100644 index 000000000..848b47161 --- /dev/null +++ b/templates/email/referees/invite_contributor_to_referee_reminder1.html @@ -0,0 +1,29 @@ +<p> + Dear {{invitation.referee.get_title_display}} {{invitation.referee.user.last_name}}, +</p> +<p> + Recently, on behalf of the Editor-in-charge {{ invitation.submission.editor_in_charge.get_title_display }} {{ invitation.submission.editor_in_charge.user.last_name }}, we invited you to consider refereeing a Submission to {{ invitation.submission.get_submitted_to_journal_display }}, namely<br><br> + {{ invitation.submission.title }}<br> + by {{ invitation.submission.author_list }}<br> + (see https://scipost.org{{ invitation.submission.get_absolute_url }} - first submitted {{ invitation.submission.original_submission_date|date:"d M Y" }}). +</p> +<p> + We are still awaiting your response to this invitation. + To ensure timely processing of the submission (out of respect for the authors), + could you please let us know whether we can count on your expertise? +</p> +<p> + Please <a href="https://scipost.org/submissions/accept_or_decline_ref_invitations">accept or decline</a> (login required) this invitation. +</p> +<p> + If you accept, your report can be submitted by simply clicking on the "Contribute a Report" link on <a href="https://scipost.org{{invitation.submission.get_absolute_url}}">the Submission Page</a> before the reporting deadline (currently set at {{invitation.submission.reporting_deadline|date:'d M Y'}}; your report will be automatically recognized as an invited report). +</p> +<p> + You might want to make sure you are familiar with our refereeing <a href="https://scipost.org/journals/journals_terms_and_conditions">code of conduct</a> and with <a href="https://scipost.org/submissions/sub_and_ref_procedure">the refereeing procedure</a>. +</p> +<p> + We would be extremely grateful for your contribution, and thank you in advance for your consideration. + <br> + The SciPost Team. +</p> +{% include 'email/_footer.html' %} diff --git a/templates/email/referees/invite_contributor_to_referee_reminder1.json b/templates/email/referees/invite_contributor_to_referee_reminder1.json new file mode 100644 index 000000000..efffa7486 --- /dev/null +++ b/templates/email/referees/invite_contributor_to_referee_reminder1.json @@ -0,0 +1,8 @@ +{ + "subject": "SciPost: refereeing request reminder", + "to_address": "referee.user.email", + "bcc_to": "submission.editor_in_charge.user.email,admin@scipost.org", + "from_address_name": "SciPost Refereeing", + "from_address": "refereeing@scipost.org", + "context_object": "invitation" +} diff --git a/templates/email/referees/invite_unregistered_to_referee_reminder1.html b/templates/email/referees/invite_unregistered_to_referee_reminder1.html new file mode 100644 index 000000000..b8d8862f6 --- /dev/null +++ b/templates/email/referees/invite_unregistered_to_referee_reminder1.html @@ -0,0 +1,34 @@ +<p> + Dear {{ invitation.get_title_display }} {{ invitation.last_name }}, +</p> +<p> + Recently, on behalf of the Editor-in-charge {{ invitation.submission.editor_in_charge.get_title_display }} {{ invitation.submission.editor_in_charge.user.last_name }}, we invited you to consider refereeing a Submission to {{ invitation.submission.get_submitted_to_journal_display }}, namely<br><br> + {{ invitation.submission.title }}<br> + by {{ invitation.submission.author_list }}<br> + (see https://scipost.org{{ invitation.submission.get_absolute_url }} - first submitted {{ invitation.submission.original_submission_date|date:"d M Y" }}). +</p> +<p> + We are still awaiting your response to this invitation. + To ensure timely processing of the submission (out of respect for the authors), + could you please let us know whether we can count on your expertise? +</p> +<p> + If you are <strong>not</strong> able to provide a Report, you can let us know by simply <a href="https://scipost.org/submissions/decline_ref_invitation/{{ invitation.invitation_key }}"> clicking here</a>. +</p> +<p> + If you are able to provide a Report, you can confirm this after registering and logging in (you will automatically be prompted for a confirmation). +</p> +<p> + We would thus hereby like to cordially invite you to become a Contributor on SciPost (this is required in order to deliver reports; our records show that you are not yet registered); + for your convenience, we have prepared a pre-filled <a href="https://scipost.org/invitation/{{ invitation.invitation_key }}">registration form</a> for you. + After activation of your registration, you will be allowed to contribute, in particular by providing referee reports. +</p> +<p> + We very much hope that we can count on your expertise, + <br> + Many thanks in advance, + <br> + The SciPost Team +</p> + +{% include 'email/_footer.html' %} diff --git a/templates/email/referees/invite_unregistered_to_referee_reminder1.json b/templates/email/referees/invite_unregistered_to_referee_reminder1.json new file mode 100644 index 000000000..3bbadb417 --- /dev/null +++ b/templates/email/referees/invite_unregistered_to_referee_reminder1.json @@ -0,0 +1,8 @@ +{ + "subject": "SciPost: refereeing and registration invitation reminder", + "to_address": "email_address", + "bcc_to": "invited_by.email,admin@scipost.org", + "from_address_name": "SciPost Refereeing", + "from_address": "refereeing@scipost.org", + "context_object": "invitation" +} diff --git a/templates/email/referees/remind_referee_deadline_1week.html b/templates/email/referees/remind_referee_deadline_1week.html new file mode 100644 index 000000000..b9e9f9ddf --- /dev/null +++ b/templates/email/referees/remind_referee_deadline_1week.html @@ -0,0 +1,16 @@ +<p> + Dear {{invitation.referee.get_title_display}} {{invitation.referee.user.last_name}}, +</p> +<p> + This is a simple email to remind you of the approaching deadline (in one week) to send a Report on + <br><br> + <a href="https://scipost.org{{invitation.submission.get_absolute_url}}">{{invitation.submission.title}}</a> + <br>by {{invitation.submission.author_list}}<br> + (see https://scipost.org{{ invitation.submission.get_absolute_url }} - first submitted {{ invitation.submission.original_submission_date|date:"d M Y" }}). +</p> +<p> + Thank you in advance, + <br> + The SciPost Team. +</p> +{% include 'email/_footer.html' %} diff --git a/templates/email/referees/remind_referee_deadline_1week.json b/templates/email/referees/remind_referee_deadline_1week.json new file mode 100644 index 000000000..e029914ea --- /dev/null +++ b/templates/email/referees/remind_referee_deadline_1week.json @@ -0,0 +1,8 @@ +{ + "subject": "SciPost: refereeing deadline approaching", + "to_address": "referee.user.email", + "bcc_to": "submission.editor_in_charge.user.email,admin@scipost.org", + "from_address_name": "SciPost Refereeing", + "from_address": "refereeing@scipost.org", + "context_object": "invitation" +} -- GitLab