SciPost Code Repository

Skip to content
Snippets Groups Projects
Commit f891bd95 authored by Jean-Sébastien Caux's avatar Jean-Sébastien Caux
Browse files

Add email reminders to Fellows with voting duties

parent 05f1a5e9
No related branches found
No related tags found
No related merge requests found
...@@ -34,6 +34,14 @@ $(document).ready(function(){ ...@@ -34,6 +34,14 @@ $(document).ready(function(){
{% if request.user|is_in_group:'Editorial Administrators' and recommendations_undergoing_voting %} {% if request.user|is_in_group:'Editorial Administrators' and recommendations_undergoing_voting %}
<section> <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-container">
<div class="flex-greybox"> <div class="flex-greybox">
<h1>Recommendations undergoing voting</h1> <h1>Recommendations undergoing voting</h1>
......
...@@ -79,6 +79,8 @@ urlpatterns = [ ...@@ -79,6 +79,8 @@ urlpatterns = [
# Voting # Voting
url(r'^prepare_for_voting/(?P<rec_id>[0-9]+)$', views.prepare_for_voting, name='prepare_for_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'^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 # Editorial Administration
url(r'fix_College_decision/(?P<rec_id>[0-9]+)$', views.fix_College_decision, url(r'fix_College_decision/(?P<rec_id>[0-9]+)$', views.fix_College_decision,
name='fix_College_decision'), name='fix_College_decision'),
......
import datetime 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 django.template import Context, Template
from journals.models import journals_submit_dict from journals.models import journals_submit_dict
...@@ -1220,3 +1220,40 @@ class SubmissionUtils(object): ...@@ -1220,3 +1220,40 @@ class SubmissionUtils(object):
reply_to=['submissions@scipost.org']) reply_to=['submissions@scipost.org'])
emailmessage.attach_alternative(html_version, 'text/html') emailmessage.attach_alternative(html_version, 'text/html')
emailmessage.send(fail_silently=False) 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)
...@@ -1339,6 +1339,36 @@ def vote_on_rec(request, rec_id): ...@@ -1339,6 +1339,36 @@ def vote_on_rec(request, rec_id):
return redirect(reverse('submissions:pool')) 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) @permission_required('scipost.can_fix_College_decision', raise_exception=True)
@transaction.atomic @transaction.atomic
def fix_College_decision(request, rec_id): def fix_College_decision(request, rec_id):
......
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