From 8e09206fecffa9c7369e39bd59897ecb54d6c105 Mon Sep 17 00:00:00 2001 From: Jorran de Wit <jorrandewit@outlook.com> Date: Fri, 20 Apr 2018 17:49:49 +0200 Subject: [PATCH] Improve unassigned Submission rejection view --- .../submissions_assignment_failed.html | 17 +++++ .../submissions_assignment_failed.json | 8 +++ mails/templates/mails/mail_form.html | 8 ++- mails/views.py | 6 ++ .../admin/editorial_assignment_failed.html | 13 ++++ .../admin/editorial_assignment_failed.html | 18 ------ submissions/utils.py | 62 ------------------- submissions/views.py | 42 ++++++------- 8 files changed, 71 insertions(+), 103 deletions(-) create mode 100644 mails/templates/mail_templates/submissions_assignment_failed.html create mode 100644 mails/templates/mail_templates/submissions_assignment_failed.json create mode 100644 submissions/templates/partials/submissions/admin/editorial_assignment_failed.html delete mode 100644 submissions/templates/submissions/admin/editorial_assignment_failed.html diff --git a/mails/templates/mail_templates/submissions_assignment_failed.html b/mails/templates/mail_templates/submissions_assignment_failed.html new file mode 100644 index 000000000..382b42174 --- /dev/null +++ b/mails/templates/mail_templates/submissions_assignment_failed.html @@ -0,0 +1,17 @@ +<p>Dear {{ submission.submitted_by.get_title_display }} {{ submission.submitted_by.user.last_name }},</p> +<p>Your recent Submission to SciPost,</p> +<p>{{ submission.title }}</p> +<p>by {{ submission.author_list }}</p> +<p> + has unfortunately not passed the pre-screening stage. + We therefore regret to inform you that we will not + process your paper further towards publication, and that you + are now free to send your manuscript to an alternative journal. +</p> + + +<p>We nonetheless thank you very much for your contribution.</p> +<p>Sincerely,</p> +<p>The SciPost Team.</p> + +{% include 'email/_footer.html' %} diff --git a/mails/templates/mail_templates/submissions_assignment_failed.json b/mails/templates/mail_templates/submissions_assignment_failed.json new file mode 100644 index 000000000..9b1051a0b --- /dev/null +++ b/mails/templates/mail_templates/submissions_assignment_failed.json @@ -0,0 +1,8 @@ +{ + "subject": "SciPost: pre-screening not passed", + "to_address": "submitted_by.user.email", + "bcc_to": "submissions@scipost.org", + "from_address_name": "SciPost Editorial Admin", + "from_address": "submissions@scipost.org", + "context_object": "submission" +} diff --git a/mails/templates/mails/mail_form.html b/mails/templates/mails/mail_form.html index f1afc1a87..6bae596d9 100644 --- a/mails/templates/mails/mail_form.html +++ b/mails/templates/mails/mail_form.html @@ -6,7 +6,13 @@ {% block content %} - <h1>Complete and send mail</h1> + {% if header_template %} + {% include header_template with object=object %} + <hr class="divider"> + <h2 class="highlight">Complete and send mail</h2> + {% else %} + <h1 class="highlight">Complete and send mail</h1> + {% endif %} <h3 class="mb-4">You may edit the mail before sending it.</h3> <form enctype="multipart/form-data" method="post"> diff --git a/mails/views.py b/mails/views.py index 6132d3923..36578a74a 100644 --- a/mails/views.py +++ b/mails/views.py @@ -15,6 +15,7 @@ class MailEditingSubView(object): self.request = request self.context = kwargs.get('context', {}) self.template_name = kwargs.get('template', 'mails/mail_form.html') + self.header_template = kwargs.get('header_template', '') self.mail_form = EmailTemplateForm(request.POST or None, mail_code=mail_code, **kwargs) @property @@ -38,6 +39,11 @@ class MailEditingSubView(object): def return_render(self): self.context['form'] = self.mail_form + self.context['header_template'] = self.header_template + if hasattr(self.mail_form, 'instance') and self.mail_form.instance: + self.context['object'] = self.mail_form.instance + else: + self.context['object'] = None return render(self.request, self.template_name, self.context) diff --git a/submissions/templates/partials/submissions/admin/editorial_assignment_failed.html b/submissions/templates/partials/submissions/admin/editorial_assignment_failed.html new file mode 100644 index 000000000..09bd150d8 --- /dev/null +++ b/submissions/templates/partials/submissions/admin/editorial_assignment_failed.html @@ -0,0 +1,13 @@ +<h1 class="highlight">Assignment has failed for Submission</h1> +<h3>Submission details</h3> +{% include 'partials/submissions/submission_summary.html' with submission=object %} + +<br> +<h3>Current EIC assignment requests:</h3> +<ul> + {% for assignment in object.editorial_assignments.all %} + {% include 'partials/submissions/pool/assignment_info.html' with assignment=assignment %} + {% empty %} + <li>No assignment requests have been sent</li> + {% endfor %} +</ul> diff --git a/submissions/templates/submissions/admin/editorial_assignment_failed.html b/submissions/templates/submissions/admin/editorial_assignment_failed.html deleted file mode 100644 index cd2931bea..000000000 --- a/submissions/templates/submissions/admin/editorial_assignment_failed.html +++ /dev/null @@ -1,18 +0,0 @@ -{% extends 'scipost/base.html' %} - -{% load bootstrap %} - -{% block pagetitle %}: assignment failed (ack){% endblock pagetitle %} - -{% block content %} - -<h1>Assignment has failed for Submission</h1> -<p>{{ submission.title }} by {{ submission.author_list }}.</p> -<p>Please add comments on the Submission in this box.</p> -<form action="{% url 'submissions:assignment_failed' arxiv_identifier_w_vn_nr=submission.arxiv_identifier_w_vn_nr %}" method="POST"> - {% csrf_token %} - {{ form|bootstrap }} - <input type="submit" name="Submit" class="btn btn-primary" /> -</form> - -{% endblock content %} diff --git a/submissions/utils.py b/submissions/utils.py index 44115064b..5098fbc6b 100644 --- a/submissions/utils.py +++ b/submissions/utils.py @@ -569,68 +569,6 @@ class SubmissionUtils(BaseMailUtil): emailmessage.attach_alternative(html_version, 'text/html') emailmessage.send(fail_silently=False) - @classmethod - def assignment_failed_email_authors(cls): - """ Requires loading 'submission' attribute. """ - email_text = ('Dear ' + cls.submission.submitted_by.get_title_display() + ' ' - + cls.submission.submitted_by.user.last_name - + ', \n\nYour recent Submission to SciPost,\n\n' - + cls.submission.title + ' by ' + cls.submission.author_list - + '\n\nhas unfortunately not passed the pre-screening stage. ' - 'We therefore regret to inform you that we will not ' - 'process your paper further towards publication, and that you ' - 'are now free to send your manuscript to an alternative journal.') - if len(cls.personal_message) > 3: - email_text += '\n\n' + cls.personal_message - email_text += ('\n\nWe nonetheless thank you very much for your contribution.' - '\n\nSincerely,' + - '\n\nThe SciPost Team.') - email_text_html = ( - '<p>Dear {{ title }} {{ last_name }},</p>' - '<p>Your recent Submission to SciPost,</p>' - '<p>{{ sub_title }}</p>' - '\n<p>by {{ author_list }}</p>' - '\n<p>has unfortunately not passed the pre-screening stage. ' - 'We therefore regret to inform you that we will not ' - 'process your paper further towards publication, and that you ' - 'are now free to send your manuscript to an alternative journal.</p>') - if len(cls.personal_message) > 3: - email_text_html += '{{ personal_message|linebreaks }}' - email_text_html += ( - '<p>We nonetheless thank you very much for your contribution.</p>' - '<p>Sincerely,</p>' - '<p>The SciPost Team.</p>') - email_context = { - 'title': cls.submission.submitted_by.get_title_display(), - 'last_name': cls.submission.submitted_by.user.last_name, - 'sub_title': cls.submission.title, - 'author_list': cls.submission.author_list, - 'personal_message': cls.personal_message, - } - email_text_html += '<br/>' + EMAIL_FOOTER - html_template = Template(email_text_html) - html_version = html_template.render(Context(email_context)) - emailmessage = EmailMultiAlternatives( - 'SciPost: pre-screening not passed', email_text, - 'SciPost Editorial Admin <submissions@scipost.org>', - [cls.submission.submitted_by.user.email], - bcc=['submissions@scipost.org'], - reply_to=['submissions@scipost.org']) - emailmessage.attach_alternative(html_version, 'text/html') - emailmessage.send(fail_silently=False) - - @classmethod - def send_refereeing_invitation_email(cls): - """ - This method is called by send_refereeing_invitation in submissions/views. - It is used when the referee is already a registered contributor. - If a referee is not yet registered, the method recruit_referee is used - instead, which calls the send_registration_email method in scipost/utils. - Requires loading 'invitation' attribute. - """ - raise DeprecationWarning(('Use new mails.views.MailEditingSubView() with code' - ' `submission_referee_invite` instead')) - @classmethod def send_unreg_ref_reminder_email(cls): """ diff --git a/submissions/views.py b/submissions/views.py index 41626f628..110770e9f 100644 --- a/submissions/views.py +++ b/submissions/views.py @@ -25,7 +25,7 @@ from django.views.generic.list import ListView from guardian.shortcuts import assign_perm from .constants import STATUS_VETTED, STATUS_EIC_ASSIGNED,\ - SUBMISSION_STATUS_PUBLICLY_INVISIBLE, SUBMISSION_STATUS,\ + SUBMISSION_STATUS_PUBLICLY_INVISIBLE, SUBMISSION_STATUS, STATUS_ASSIGNMENT_FAILED,\ STATUS_DRAFT, CYCLE_DIRECT_REC, STATUS_VOTING_IN_PREPARATION,\ STATUS_PUT_TO_EC_VOTING from .models import Submission, EICRecommendation, EditorialAssignment,\ @@ -606,28 +606,26 @@ def assignment_failed(request, arxiv_identifier_w_vn_nr): """ submission = get_object_or_404(Submission.objects.pool(request.user).prescreening(), arxiv_identifier_w_vn_nr=arxiv_identifier_w_vn_nr) - if request.method == 'POST': - form = ModifyPersonalMessageForm(request.POST) - if form.is_valid(): - submission.status = 'assignment_failed' - submission.latest_activity = timezone.now() - submission.save() - SubmissionUtils.load({'submission': submission, - 'personal_message': form.cleaned_data['personal_message']}) - SubmissionUtils.deprecate_all_assignments() - SubmissionUtils.assignment_failed_email_authors() - context = {'ack_header': ('Submission ' + submission.arxiv_identifier_w_vn_nr + - ' has failed pre-screening and been rejected. ' - 'Authors have been informed by email.'), - 'followup_message': 'Return to the ', - 'followup_link': reverse('submissions:pool'), - 'followup_link_label': 'Submissions pool'} - return render(request, 'scipost/acknowledgement.html', context) + + mail_request = MailEditingSubView( + request, mail_code='submissions_assignment_failed', instance=submission, + header_template='partials/submissions/admin/editorial_assignment_failed.html') + if mail_request.is_valid(): + # Deprecate old Editorial Assignments + EditorialAssignment.objects.filter(submission=submission).open().update(deprecated=True) + + # Update status of Submission + submission.touch() + Submission.objects.filter(id=submission.id).update(status=STATUS_ASSIGNMENT_FAILED) + + messages.success( + request, 'Submission {arxiv} has failed pre-screening and been rejected.'.format( + arxiv=submission.arxiv_identifier_w_vn_nr)) + messages.success(request, 'Authors have been informed by email.') + mail_request.send() + return redirect(reverse('submissions:pool')) else: - form = ModifyPersonalMessageForm() - context = {'submission': submission, - 'form': form} - return render(request, 'submissions/admin/editorial_assignment_failed.html', context) + return mail_request.return_render() @login_required -- GitLab