diff --git a/submissions/templates/submissions/pool.html b/submissions/templates/submissions/pool.html index 619280fbb5738553542cd902ae7be885755ff01e..6f7db2515e4d59490572adf53ae5429908a88898 100644 --- a/submissions/templates/submissions/pool.html +++ b/submissions/templates/submissions/pool.html @@ -34,6 +34,14 @@ $(document).ready(function(){ {% if request.user|is_in_group:'Editorial Administrators' and recommendations_undergoing_voting %} <section> + <div class="flex-container"> + <div class="flex-whitebox"> + <h3>Administrative actions on recommendations undergoing voting:</h3> + <ul> + <li>To send an email reminder to each Fellow with at least one voting duty, <a href="{% url 'submissions:remind_Fellows_to_vote' %}">click here</a></li> + </ul> + </div> + </div> <div class="flex-container"> <div class="flex-greybox"> <h1>Recommendations undergoing voting</h1> diff --git a/submissions/urls.py b/submissions/urls.py index 4f6f260968f1759f6266c66ea14b4ecf87ff2016..1f0a6d82c2eab36a20f2e1d99afcf4c82345e80f 100644 --- a/submissions/urls.py +++ b/submissions/urls.py @@ -79,6 +79,8 @@ urlpatterns = [ # Voting url(r'^prepare_for_voting/(?P<rec_id>[0-9]+)$', views.prepare_for_voting, name='prepare_for_voting'), url(r'^vote_on_rec/(?P<rec_id>[0-9]+)$', views.vote_on_rec, name='vote_on_rec'), + url(r'^remind_Fellows_to_vote$', views.remind_Fellows_to_vote, + name='remind_Fellows_to_vote'), # Editorial Administration url(r'fix_College_decision/(?P<rec_id>[0-9]+)$', views.fix_College_decision, name='fix_College_decision'), diff --git a/submissions/utils.py b/submissions/utils.py index 6d2e0c65d65a5cf5bf2b470d2210ecf6e9dc7492..5a6e4197c26e877feca63afeb7a4cc50bbb0ed6e 100644 --- a/submissions/utils.py +++ b/submissions/utils.py @@ -1,6 +1,6 @@ import datetime -from django.core.mail import EmailMessage, EmailMultiAlternatives +from django.core.mail import EmailMessage, EmailMultiAlternatives, get_connection from django.template import Context, Template from journals.models import journals_submit_dict @@ -1220,3 +1220,40 @@ class SubmissionUtils(object): reply_to=['submissions@scipost.org']) emailmessage.attach_alternative(html_version, 'text/html') emailmessage.send(fail_silently=False) + + + @classmethod + def send_Fellows_voting_reminder_email(cls): + """ + Requires loading 'Fellow_emails' attribute, which is a list of email addresses. + """ + email_text = ('Dear Fellow,' + '\n\nYou have pending voting duties in the SciPost ' + 'submissions pool at https://scipost.org/submissions/pool' + ' (also accessible from your personal page ' + 'https://scipost.org/personal_page under the Editorial Actions tab). ' + 'Could you please have a quick look within the next couple of days, ' + 'so we can finish processing these submissions?' + '\n\nMany thanks in advance,' + '\n\nThe SciPost Team.') + email_text_html = ( + '<p>Dear Fellow,</p>' + '<p>You have pending voting duties in the SciPost ' + 'submissions pool https://scipost.org/submissions/pool' + ' (also accessible from your personal page ' + 'https://scipost.org/personal_page under the Editorial Actions tab).</p>' + '<p>Could you please have a quick look within the next couple of days, ' + 'so we can finish processing these submissions?</p>' + '<p>Many thanks in advance,</p>' + '<p>The SciPost Team.</p><br/>' + EMAIL_FOOTER) + email_context = Context({}) + html_template = Template(email_text_html) + html_version = html_template.render(email_context) + emailmessage = EmailMultiAlternatives( + 'SciPost: voting duties', email_text, + 'SciPost Editorial Admin <admin@scipost.org>', + to=['admin@scipost.org'], + bcc=cls.Fellow_emails, + reply_to=['admin@scipost.org']) + emailmessage.attach_alternative(html_version, 'text/html') + emailmessage.send(fail_silently=False) diff --git a/submissions/views.py b/submissions/views.py index d915f89e6b5335709d55a1e1ca26ad0bbc93ba71..1eba43716a98a0ceeaa45555cf1a474bca506240 100644 --- a/submissions/views.py +++ b/submissions/views.py @@ -1339,6 +1339,36 @@ def vote_on_rec(request, rec_id): return redirect(reverse('submissions:pool')) +@permission_required('scipost.can_prepare_recommendations_for_voting', raise_exception=True) +def remind_Fellows_to_vote(request): + """ + This method sends an email to all Fellow with pending voting duties. + It must be called by and Editorial Administrator. + """ + recommendations_undergoing_voting = (EICRecommendation.objects.filter( + submission__status__in=['put_to_EC_voting'])) + Fellow_emails = [] + Fellow_names = [] + for rec in recommendations_undergoing_voting: + for Fellow in rec.eligible_to_vote.all(): + if (Fellow not in rec.voted_for.all() + and Fellow not in rec.voted_against.all() + and Fellow not in rec.voted_abstain.all()): + Fellow_emails.append(Fellow.user.email) + Fellow_names.append(str(Fellow)) + SubmissionUtils.load({'Fellow_emails': Fellow_emails}) + SubmissionUtils.send_Fellows_voting_reminder_email() + ack_message = 'Email reminders have been sent to: <ul>' + for name in sorted(Fellow_names): + ack_message += '<li>' + name + '</li>' + ack_message += '</ul>' + context = {'ack_message': Template(ack_message).render(Context({})), + 'followup_message': 'Return to the ', + 'followup_link': reverse('submissions:pool'), + 'followup_link_label': 'Submissions pool'} + return render (request, 'scipost/acknowledgement.html', context) + + @permission_required('scipost.can_fix_College_decision', raise_exception=True) @transaction.atomic def fix_College_decision(request, rec_id):