diff --git a/journals/templates/journals/manage_comment_metadata.html b/journals/templates/journals/manage_comment_metadata.html index efd231d30dac48b5caf5cf6addf0c04f7f0663c8..d51e10289d8b5cf78f7e63ad757bf83667252c82 100644 --- a/journals/templates/journals/manage_comment_metadata.html +++ b/journals/templates/journals/manage_comment_metadata.html @@ -48,6 +48,7 @@ event: "focusin" <ul> <li>Mark DOI as <a href="{% url 'journals:mark_comment_doi_needed' comment_id=comment.id needed=1 %}">needed</a> / <a href="{% url 'journals:mark_comment_doi_needed' comment_id=comment.id needed=0 %}">not needed</a></li> <li><a href="{% url 'journals:generic_metadata_xml_deposit' type_of_object='comment' object_id=comment.id %}">Create the metadata and deposit it to Crossref</a></li> + <li><a href="{% url 'journals:email_object_made_citable' type_of_object='comment' object_id=comment.id %}">Email comment author: made citable</a> </ul> <h2 class="ml-3">Crossref Deposits</h2> diff --git a/journals/templates/journals/manage_report_metadata.html b/journals/templates/journals/manage_report_metadata.html index 9d491ccecc3aa31612ba24beca5503d0e33114cf..d3527992536cd500a9f7c344ef0c527634906504 100644 --- a/journals/templates/journals/manage_report_metadata.html +++ b/journals/templates/journals/manage_report_metadata.html @@ -63,6 +63,7 @@ event: "focusin" <ul> <li>Mark DOI as <a href="{% url 'journals:mark_report_doi_needed' report_id=report.id needed=1 %}">needed</a> / <a href="{% url 'journals:mark_report_doi_needed' report_id=report.id needed=0 %}">not needed</a></li> <li><a href="{% url 'journals:generic_metadata_xml_deposit' type_of_object='report' object_id=report.id %}">Create the metadata and deposit it to Crossref</a></li> + <li><a href="{% url 'journals:email_object_made_citable' type_of_object='report' object_id=report.id %}">Email report author: made citable</a> </ul> <h2 class="ml-3">Crossref Deposits</h2> diff --git a/journals/urls/general.py b/journals/urls/general.py index fe28da6578e252e6d3521331a7673122159998ba..dd9cfea9eab02f3c9e99417c5d25887fd7b75956 100644 --- a/journals/urls/general.py +++ b/journals/urls/general.py @@ -109,4 +109,7 @@ urlpatterns = [ url(r'^mark_generic_deposit_success/(?P<deposit_id>[0-9]+)/(?P<success>[0-1])$', journals_views.mark_generic_deposit_success, name='mark_generic_deposit_success'), + url(r'^email_object_made_citable/(?P<type_of_object>[a-z]+)/(?P<object_id>[0-9]+)$', + journals_views.email_object_made_citable, + name='email_object_made_citable'), ] diff --git a/journals/utils.py b/journals/utils.py index e80f921bf073307bae433d1060bcafff19f6f17c..5b3d5e1dae0d830a467b323b869adceb2246cd57 100644 --- a/journals/utils.py +++ b/journals/utils.py @@ -1,12 +1,11 @@ from django.core.mail import EmailMessage +from scipost.utils import EMAIL_FOOTER +from common.utils import BaseMailUtil -class JournalUtils(object): - @classmethod - def load(cls, dict): - for var_name in dict: - setattr(cls, var_name, dict[var_name]) +class JournalUtils(BaseMailUtil): + @classmethod def send_authors_paper_published_email(cls): @@ -88,3 +87,18 @@ class JournalUtils(object): } } return md + + + @classmethod + def email_report_made_citable(cls): + """ Requires loading 'report' attribute. """ + cls._send_mail(cls, 'email_report_made_citable', + [cls._context['report'].author.user.email], + 'Report made citable') + + @classmethod + def email_comment_made_citable(cls): + """ Requires loading 'comment' attribute. """ + cls._send_mail(cls, 'email_comment_made_citable', + [cls._context['comment'].author.user.email], + 'Comment made citable') diff --git a/journals/views.py b/journals/views.py index 06edc2905c7199c411b8dce3f7207e9d0adf349d..fd11f313cc208a32865f2d951776222ce8541a96 100644 --- a/journals/views.py +++ b/journals/views.py @@ -1263,6 +1263,30 @@ def mark_generic_deposit_success(request, deposit_id, success): return redirect(reverse('journals:manage_comment_metadata')) +@permission_required('scipost.can_publish_accepted_submission', return_403=True) +def email_object_made_citable(request, **kwargs): + """ + This method sends an email to the author of a Report or a Comment, + to notify that the object has been made citable (doi registered). + """ + type_of_object = kwargs['type_of_object'] + object_id = int(kwargs['object_id']) + + if type_of_object == 'report': + _object = get_object_or_404(Report, id=object_id) + elif type_of_object == 'comment': + _object = get_object_or_404(Comment, id=object_id) + + if type_of_object == 'report': + JournalUtils.load({'report': _object, }) + JournalUtils.email_report_made_citable() + return redirect(reverse('journals:manage_report_metadata')) + else: + JournalUtils.load({'comment': _object, }) + JournalUtils.email_comment_made_citable() + return redirect(reverse('journals:manage_comment_metadata')) + + ########### # Viewing # ########### diff --git a/templates/email/email_comment_made_citable.html b/templates/email/email_comment_made_citable.html new file mode 100644 index 0000000000000000000000000000000000000000..794bb252eff5c554c21b1b7007f7874df1b7f13f --- /dev/null +++ b/templates/email/email_comment_made_citable.html @@ -0,0 +1,18 @@ +<p>Dear {{ comment.author.get_title_display }} {{ comment.author.user.last_name }},</p> + +<p> + The Comment you have submitted, concerning publication with title + + {{comment.core_content_object.title}} by {% if comment.core_content_object.author_list %}{{comment.core_content_object.author_list}}{% elif comment.core_content_object.author %}{{comment.core_content_object.author}}{% endif %} (<a href="https://scipost.org{{comment.get_absolute_url}}">see on SciPost.org</a>) + has been ascribed DOI {{ comment.doi_label }}, and is thus now citable in the form: +</p> +<p> + {{ comment.citation }}. +</p> +<p> + Thank you again very much for your contribution.<br><br> + The SciPost Team +</p> + + +{% include 'email/_footer.html' %} diff --git a/templates/email/email_comment_made_citable.txt b/templates/email/email_comment_made_citable.txt new file mode 100644 index 0000000000000000000000000000000000000000..bd47711e3493ccc42ab7f6869ec6535ab0ed22e8 --- /dev/null +++ b/templates/email/email_comment_made_citable.txt @@ -0,0 +1,7 @@ +Dear {{ comment.author.get_title_display }} {{ comment.author.user.last_name }},\n\n +The Comment you have submitted, concerning publication with title\n +{{comment.core_content_object.title}} by {% if comment.core_content_object.author_list %}{{comment.core_content_object.author_list}}{% elif comment.core_content_object.author %}{{comment.core_content_object.author}}{% endif %} (https://scipost.org{{comment.get_absolute_url}})\n +has been ascribed DOI {{ comment.doi_label }}, and is thus now citable in the form:\n\n +{{ comment.citation }}.\n\n +Thank you again very much for your contribution.\n +The SciPost Team diff --git a/templates/email/email_report_made_citable.html b/templates/email/email_report_made_citable.html new file mode 100644 index 0000000000000000000000000000000000000000..384edf7d52926acb400d5e1d496d6feb670f435a --- /dev/null +++ b/templates/email/email_report_made_citable.html @@ -0,0 +1,22 @@ +<p>Dear {{ report.author.get_title_display }} {{ report.author.user.last_name }},</p> + +<p> + Your Report on Submission: +</p> +<p> + {{ report.submission.title }} + <br/> + by {{ report.submission.author_list }} +</p> +<p> + has been ascribed DOI {{ report.doi_label }}, and is thus now citable in the form: +</p> +<p> + {{ report.citation }}. +</p> +<p> + We thank you again very much for your contribution.<br/> + The SciPost Team +</p> + +{% include 'email/_footer.html' %} diff --git a/templates/email/email_report_made_citable.txt b/templates/email/email_report_made_citable.txt new file mode 100644 index 0000000000000000000000000000000000000000..e252b6c4d857d971a40472bd19efa89c2c0a5728 --- /dev/null +++ b/templates/email/email_report_made_citable.txt @@ -0,0 +1,8 @@ +Dear {{ report.author.get_title_display }} {{ report.author.user.last_name }},\n\n +Your Report on Submission:\n\n +{{ report.submission.title }}\n +by {{ report.submission.author_list }}\n\n +has been ascribed DOI {{ report.doi_label }}, and is thus now citable in the form:\n\n +{{ report.citation }}.\n\n +We thank you again very much for your contribution.\n +The SciPost Team