diff --git a/submissions/management/commands/email_fellows_tasklist.py b/submissions/management/commands/email_fellows_tasklist.py new file mode 100644 index 0000000000000000000000000000000000000000..90d19e235d32e34e3e572bebe9b7c49f0d718316 --- /dev/null +++ b/submissions/management/commands/email_fellows_tasklist.py @@ -0,0 +1,25 @@ +from django.core.management import BaseCommand + +from ...models import Submission, EditorialAssignment +from ...utils import SubmissionUtils + +from scipost.models import Contributor + + +class Command(BaseCommand): + help = 'Sends an email to Fellows with current and upcoming tasks list' + def handle(self, *args, **kwargs): + fellows = Contributor.objects.fellows( + ).filter(user__last_name__startswith='B' # temporary limitation, to ease testing + ).order_by('user__last_name') + + for fellow in fellows: + submissions_as_eic = Submission.objects.filter( + editor_in_charge=fellow).order_by('submission_date') + assignments_to_consider = EditorialAssignment.objects.open().filter( + to=fellow) + if submissions_as_eic or assignments_to_consider: + SubmissionUtils.load({'fellow': fellow, + 'submissions_as_eic': submissions_as_eic, + 'assignments_to_consider': assignments_to_consider,}) + SubmissionUtils.email_Fellow_tasklist() diff --git a/submissions/utils.py b/submissions/utils.py index 90fad6bad125cb646f92ac9ceea5b9094835cbef..aacecf3feefd9e009a7a079fb2d86ea6554603e2 100644 --- a/submissions/utils.py +++ b/submissions/utils.py @@ -1368,3 +1368,17 @@ class SubmissionUtils(BaseMailUtil): reply_to=['admin@scipost.org']) emailmessage.attach_alternative(html_version, 'text/html') emailmessage.send(fail_silently=False) + + + @classmethod + def email_Fellow_tasklist(cls): + """ + Email list of current and upcoming tasks to an individual Fellow. + + Requires context to contain: + - `fellow` + """ + cls._send_mail(cls, 'email_fellow_tasklist', +# [cls._context['fellow'].email_address], + ['jscaux@scipost.org'], # temporary, for testing + 'Current and upcoming tasks') diff --git a/templates/email/email_fellow_tasklist.html b/templates/email/email_fellow_tasklist.html new file mode 100644 index 0000000000000000000000000000000000000000..18721cefae72a974ad869f26aaa291747b741d91 --- /dev/null +++ b/templates/email/email_fellow_tasklist.html @@ -0,0 +1,35 @@ +{% load submissions_extras %} +<p>Dear {{ fellow.get_title_display }} {{ fellow.user.last_name }},</p> +<p>Please find below a digest of your pending and upcoming required actions as SciPost Fellow. Many thanks in advance for your timely invervention.</p> +{% if assignments_to_consider %} +<h3>Assignments for you to consider:</h3> +<ul> +{% for assignment in assignments_to_consider %} +<li>On submission: {{ assignment.submission }}<br> + <a href="{% url 'submissions:assignment_request' assignment.id %}">Accept or decline here</a> +</li> +{% endfor %} +</ul> +{% endif %} +{% if submissions_as_eic %} +<h3>Submissions for which you are Editor-in-charge:</h3> +<ul> +{% for submission in submissions_as_eic %} +<li> +<div class="pool-item"> + <p class="mb-1"> + <a href="{% url 'submissions:pool' submission.arxiv_identifier_w_vn_nr %}">{{ submission.title }}</a><br> + <em>by {{ submission.author_list }}</em> + </p> + <p><a href="{% url 'submissions:editorial_page' submission.arxiv_identifier_w_vn_nr %}">Go to this Submission's Editorial page</a></p> + {% include 'submissions/_required_actions_block.html' with submission=submission %} +</div> +</li> +{% endfor %} +</ul> +{% endif %} +<p> + Many thanks for your work,<br> + The SciPost Team. +</p> +{% include 'email/_footer.html' %} diff --git a/templates/email/email_fellow_tasklist.txt b/templates/email/email_fellow_tasklist.txt new file mode 100644 index 0000000000000000000000000000000000000000..eaa14516ca346dffa08f33872b07483c742a9d88 --- /dev/null +++ b/templates/email/email_fellow_tasklist.txt @@ -0,0 +1,29 @@ +{% load submissions_extras %} +Dear {{ fellow.get_title_display }} {{ fellow.user.last_name }},\n\n +Please find below a digest of your pending and upcoming required actions as SciPost Fellow. Many thanks in advance for your timely invervention.\n\n +{% if assignments_to_consider %} +Assignments for you to consider:\n\n +{% for assignment in assignments_to_consider %} +On submission: {{ assignment.submission }}\n +Accept or decline at {% url 'submissions:assignment_request' assignment.id %}" +{% endfor %} +{% endif %} +{% if submissions_as_eic %} +Submissions for which you are Editor-in-charge:\n\n +{% for submission in submissions_as_eic %} +{{ submission.title }}\n +by {{ submission.author_list }}\n\n +{% if submission.cycle.has_required_actions %} +Required actions:\n +{% for action in submission.cycle.get_required_actions %} +{{action.1}}\n +{% empty %} +No actions required\n +{% endfor %} +{% endif %} +{% endfor %} +{% endif %} +\n +You can take action on all of these starting from your personal page at https://scipost.org/personal_page.\n\n +Many thanks for your work,\n +The SciPost Team.