diff --git a/scipost/admin.py b/scipost/admin.py index 836a0893fe4b1b98652117fcd43de2c14c2b3d13..33b6a2d3ac0f8aecdcec5c1bfdec4c130f688b60 100644 --- a/scipost/admin.py +++ b/scipost/admin.py @@ -41,6 +41,12 @@ admin.site.register(AuthorshipClaim) admin.site.register(Permission) +class PrecookedEmailAdmin(admin.ModelAdmin): + search_fields = ['email_subject', 'email_text', 'emailed_to'] + +admin.site.register(PrecookedEmail, PrecookedEmailAdmin) + + class NewsItemAdmin(admin.ModelAdmin): search_fields = ['blurb', 'followup_link_text'] diff --git a/scipost/forms.py b/scipost/forms.py index 7e0f3e0871a7015a041bcf4befb52837a91fafd4..66f64f20cddcdd6b4fa9346dd726e2897c73e295 100644 --- a/scipost/forms.py +++ b/scipost/forms.py @@ -191,6 +191,15 @@ class EmailParticularForm(forms.Form): {'rows': 15, 'cols': 50, 'placeholder': 'Write your message in this box.'}) +class SendPrecookedEmailForm(forms.Form): + email_address = forms.EmailField() + email_option = forms.ModelChoiceField( + queryset=PrecookedEmail.objects.filter(deprecated=False)) + include_scipost_summary = forms.BooleanField( + required=False, initial=False, + label='Include SciPost summary at end of message') + + class CreateListForm(forms.ModelForm): class Meta: model = List diff --git a/scipost/models.py b/scipost/models.py index a925ed715f670725427d9af124ef6fb432905bf2..dc487a81da3f8197b5d24a98533cf8208963b169 100644 --- a/scipost/models.py +++ b/scipost/models.py @@ -485,6 +485,39 @@ class AuthorshipClaim(models.Model): # significance_rating = models.DecimalField(default=0, max_digits=3, decimal_places=0) +########## +# Emails # +########## + +# class EmailedTo(models.Model): +# """ +# An email address used for emailing. +# An instance is created by a method as send_precooked_email +# if the chosen message hasn't been sent to this address before. +# Helps prevent multiple emailing with same message. +# """ +# email = models.EmailField() + + +class PrecookedEmail(models.Model): + """ + Each instance contains an email template in both plain and html formats. + Can only be created by Admins. + For further use in scipost:send_precooked_email method. + """ + email_subject = models.CharField(max_length=300) + email_text = models.TextField() + email_text_html = models.TextField() + date_created = models.DateField(default=timezone.now) + #emailed_to = models.ManyToManyField(EmailedTo, blank=True) + emailed_to = ArrayField(models.EmailField(blank=True), blank=True) + date_last_used = models.DateField(default=timezone.now) + deprecated = models.BooleanField(default=False) + + def __str__(self): + return self.email_subject + + ############# # NewsItems # ############# diff --git a/scipost/templates/scipost/FAQ.html b/scipost/templates/scipost/FAQ.html index acd4c04f9a78cbd92fa1f5e389cf239486604d5f..73039fac817b2733c4f7088e3bf1de89d88d28f4 100644 --- a/scipost/templates/scipost/FAQ.html +++ b/scipost/templates/scipost/FAQ.html @@ -63,7 +63,6 @@ <h3>How do I submit my manuscript to SciPost?</h3> <p>After registering as a Contributor, simply follow the <a href="{% url 'submissions:sub_and_ref_procedure' %}">submission procedure</a>.</p> <br/> - <br/> <hr class="hr6"> <h3 id="pwr">How does peer-witnessed refereeing work?</h3> <p>This is a short summary; for a more detailed description, see our <a href="{% url 'submissions:sub_and_ref_procedure' %}">submission and refereeing procedure</a>.</p> @@ -75,6 +74,7 @@ <p>Contributors thus have additional incentives to actively participate and provide not only high-quality Submissions, but also Reports and Comments of the highest achievable professional caliber. Quality is moreover promoted by Editorial vetting of all Reports, Replies and Comments before public posting.</p> + <br/> <hr class="hr6"> <h3>Will my SciPost publications be citable?</h3> <p>Yes. All SciPost publications will obtain a unique DOI, enabling citations and metrics as per other journals. @@ -85,6 +85,7 @@ <p> Inclusion in standard citation databases can be applied for once the Journals have been operating for a short while (at least 3 months). Past experience with other new journals shows that listing typically occurs within a year of launch. Search engine-based listings are expected to pick our Journals up on a shorter timescale. </p> + <br/> <hr class="hr6"> <h3>Can I also submit my papers somewhere else?</h3> <p>No. SciPost publications or submissions under consideration for publication in SciPost Journals must not be submitted elsewhere.</p> diff --git a/scipost/templates/scipost/foundation.html b/scipost/templates/scipost/foundation.html index 18bd76b28bc3f688760328bcdaba706c0541abde..0a932ebbf992d0864710baee581f96c963a22c1e 100644 --- a/scipost/templates/scipost/foundation.html +++ b/scipost/templates/scipost/foundation.html @@ -42,7 +42,7 @@ <li>Secretary: Dr J. van Mameren</li> <li>Treasurer: Dr J. van Wezel</li> </ul> - <p>Board members do not receive any salary.</p> + <p>Board members do not receive any salary or financial compensation of any form for their work for the Foundation.</p> </div> </div> <div class="flex-whitebox320"> diff --git a/scipost/templates/scipost/personal_page.html b/scipost/templates/scipost/personal_page.html index 68693f70b44bdbc4d048e9b4f6d761582a38f571..ce667d6974200b039686b82b18a62139ee1abb85 100644 --- a/scipost/templates/scipost/personal_page.html +++ b/scipost/templates/scipost/personal_page.html @@ -244,6 +244,7 @@ <li><a href="{% url 'scipost:email_group_members' %}">Email Group Members</a></li> {% endif %} {% if perms.scipost.can_email_particulars %} + <li><a href="{% url 'scipost:send_precooked_email' %}">Send a precooked email</a></li> <li><a href="{% url 'scipost:email_particular' %}">Email a particular individual/address</a></li> {% endif %} </ul> diff --git a/scipost/templates/scipost/send_precooked_email.html b/scipost/templates/scipost/send_precooked_email.html new file mode 100644 index 0000000000000000000000000000000000000000..9070d44ea8a3d5a46babb7c98d6dd24cd0fba2f2 --- /dev/null +++ b/scipost/templates/scipost/send_precooked_email.html @@ -0,0 +1,30 @@ +{% extends 'scipost/base.html' %} + +{% block pagetitle %}: send precooked email{% endblock pagetitle %} + +{% block headsup %} + +{% load scipost_extras %} + +{% endblock headsup %} + +{% block bodysup %} + +<section> + {% if errormessage %} + <p>{{ errormessage }}</p> + {% else %} + <div class="flex-greybox"> + <h1>Send a precooked email to a particular</h1> + </div> + + <form action="{% url 'scipost:send_precooked_email' %}" method="post"> + {% csrf_token %} + {{ form.as_p }} + <input type="submit" value="Send email"/> + </form> + {% endif %} + +</section> + +{% endblock bodysup %} diff --git a/scipost/urls.py b/scipost/urls.py index fec9a206b14edba615814215f5677c04afdcdcfe..6b0577ec5c0ef5d6eafe6119bffe6f0fdc6ef62c 100644 --- a/scipost/urls.py +++ b/scipost/urls.py @@ -112,6 +112,7 @@ urlpatterns = [ #################### url('^email_group_members$', views.email_group_members, name='email_group_members'), url('^email_particular$', views.email_particular, name='email_particular'), + url('^send_precooked_email$', views.send_precooked_email, name='send_precooked_email'), ##################### # Editorial College # diff --git a/scipost/utils.py b/scipost/utils.py index ea7b007bebf697f1dc212fb80863644f683a8596..9ab5f6de9c18f2a53061757f8c861f89b366e5b2 100644 --- a/scipost/utils.py +++ b/scipost/utils.py @@ -24,7 +24,8 @@ SCIPOST_SUMMARY_FOOTER = ( 'international scientific community.' '\n\nThe site is anchored at https://scipost.org. Many further details ' 'about SciPost, its principles, ideals and implementation can be found at ' - 'https://scipost.org/about and https://scipost.org/FAQ.' + 'https://scipost.org/about and https://scipost.org/FAQ. ' + 'Professional scientists can register at https://scipost.org/register.' ) SCIPOST_SUMMARY_FOOTER_HTML = ( @@ -40,7 +41,8 @@ SCIPOST_SUMMARY_FOOTER_HTML = ( 'international scientific community.</p>' '<p>The site is anchored at https://scipost.org. Many further details ' 'about SciPost, its principles, ideals and implementation can be found at ' - 'https://scipost.org/about and https://scipost.org/FAQ.</p>' + 'https://scipost.org/about and https://scipost.org/FAQ.' + 'Professional scientists can register at https://scipost.org/register.</p>' ) diff --git a/scipost/views.py b/scipost/views.py index 585708bc3d50f4749899e76bbaca23bbb96db886..73db3faca55e89eb649f21e84476db9bb2f32b0a 100644 --- a/scipost/views.py +++ b/scipost/views.py @@ -1100,6 +1100,49 @@ def email_particular(request): return render(request, 'scipost/email_particular.html', context) +@permission_required('scipost.can_email_particulars', return_403=True) +def send_precooked_email(request): + """ + Method to send precooked emails to individuals (registered or not) + """ + if request.method == 'POST': + form = SendPrecookedEmailForm(request.POST) + if form.is_valid(): + precookedEmail = form.cleaned_data['email_option'] + if form.cleaned_data['email_address'] in precookedEmail.emailed_to: + errormessage = 'This message has already been sent to this address' + return render(request, 'scipost/error.html', + context={'errormessage': errormessage}) + precookedEmail.emailed_to.append(form.cleaned_data['email_address']) + precookedEmail.date_last_used = timezone.now().date() + precookedEmail.save() + email_text = precookedEmail.email_text + email_text_html = '{{ email_text|linebreaks }}' + email_context = Context({'email_text': precookedEmail.email_text_html}) + if form.cleaned_data['include_scipost_summary']: + email_text += SCIPOST_SUMMARY_FOOTER + email_text_html += SCIPOST_SUMMARY_FOOTER_HTML + + email_text_html += '<br/>' + EMAIL_FOOTER + html_template = Template(email_text_html) + html_version = html_template.render(email_context) + message = EmailMultiAlternatives( + precookedEmail.email_subject, + email_text, 'SciPost Admin <admin@scipost.org>', + [form.cleaned_data['email_address']], + bcc=['admin@scipost.org']) + message.attach_alternative(html_version, 'text/html') + message.send() + context = {'ack_header': 'The email has been sent.', + 'followup_message': 'Return to your ', + 'followup_link': reverse('scipost:personal_page'), + 'followup_link_label': 'personal page'} + return render(request, 'scipost/acknowledgement.html', context) + form = SendPrecookedEmailForm() + context = {'form': form} + return render(request, 'scipost/send_precooked_email.html', context) + + ##################### # Editorial College # ##################### diff --git a/submissions/utils.py b/submissions/utils.py index 4c3c02a75d386e6c0e6c056835646c78a9d63d0b..e22a298cdeaa791efb7b4539d80b8620abf39101 100644 --- a/submissions/utils.py +++ b/submissions/utils.py @@ -802,7 +802,7 @@ class SubmissionUtils(object): email_text_html = ( 'Dear {{ ref_title }} {{ ref_last_name }},' '<p>Many thanks for your Report on Submission</p>' - '<p>{{ sub_title }}</p>\n<p>by{{ author_list }}.</p>') + '<p>{{ sub_title }}</p>\n<p>by {{ author_list }}.</p>') if cls.report.status == 1: email_text += ('\n\nYour Report has been vetted through and is viewable at ' 'https://scipost.org/submissions/'