SciPost Code Repository

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

Enable emailing generic address for ProspectivePartner

parent 495ec18f
No related branches found
No related tags found
No related merge requests found
......@@ -55,6 +55,10 @@ class EmailProspectivePartnerContactForm(forms.Form):
{'placeholder': 'Write your message in this box (optional).'})
class EmailProspectivePartnerGenericForm(EmailProspectivePartnerContactForm):
email = forms.EmailField(label='Generic address for emailing')
# class ProspectivePartnerContactSelectForm(forms.Form):
# def __init__(self, *args, **kwargs):
......
......@@ -15,6 +15,7 @@
<p>{{ pp.get_status_display }}</p>
</div>
<div class="col-md-7">
<a href="{% url 'partners:email_prospartner_generic' prospartner_id=pp.id %}">Compose email to a generic address</a>
<h3>Contacts:</h3>
<a class="d-inline-block mb-2" href="{% url 'partners:add_prospartner_contact' prospartner_id=pp.id %}">Add a contact</a>
<table class="table">
......
{% extends 'scipost/base.html' %}
{% block pagetitle %}: Supporting Partners: email contact{% endblock pagetitle %}
{% load bootstrap %}
{% block content %}
<div class="row">
<div class="col-12">
<h1 class="highlight">Email a Prospective Partner Generic Address</h1>
</div>
</div>
<div class="row">
<div class="col-12">
<form action="{% url 'partners:email_prospartner_generic' prospartner_id=prospartner.id %}" method="post">
{% csrf_token %}
{{ form|bootstrap }}
<input class="btn btn-primary" type="submit" value="Submit"/>
</form>
{% if errormessage %}
<p class="text-danger">{{ errormessage }}</p>
{% endif %}
</div>
</div>
{% endblock content %}
......@@ -12,6 +12,8 @@ urlpatterns = [
views.add_prospartner_contact, name='add_prospartner_contact'),
url(r'^email_prospartner_contact/(?P<contact_id>[0-9]+)$',
views.email_prospartner_contact, name='email_prospartner_contact'),
url(r'^email_prospartner_generic/(?P<prospartner_id>[0-9]+)$',
views.email_prospartner_generic, name='email_prospartner_generic'),
url(r'^add_prospartner_event/(?P<prospartner_id>[0-9]+)$',
views.add_prospartner_event, name='add_prospartner_event'),
]
......@@ -16,3 +16,13 @@ class PartnerUtils(BaseMailUtil):
cls._send_mail(cls, 'email_prospartner_contact',
[cls._context['contact'].email,],
cls._context['email_subject'])
@classmethod
def email_prospartner_generic(cls):
"""
Email a generic address for a ProspectivePartner
for which no Contact could be defined.
"""
cls._send_mail(cls, 'email_prospartner_contact',
[cls._context['email'],],
cls._context['email_subject'])
......@@ -12,6 +12,7 @@ from .models import Partner, ProspectivePartner, ProspectiveContact,\
ProspectivePartnerEvent, MembershipAgreement
from .forms import ProspectivePartnerForm, ProspectiveContactForm,\
EmailProspectivePartnerContactForm,\
EmailProspectivePartnerGenericForm,\
ProspectivePartnerEventForm, MembershipQueryForm
from common.utils import BaseMailUtil
......@@ -129,6 +130,37 @@ def email_prospartner_contact(request, contact_id):
return render(request, 'partners/email_prospartner_contact.html', context)
@permission_required('scipost.can_email_prospartner_contact', return_403=True)
@transaction.atomic
def email_prospartner_generic(request, prospartner_id):
prospartner = get_object_or_404(ProspectivePartner, pk=prospartner_id)
form = EmailProspectivePartnerGenericForm(request.POST or None)
if form.is_valid():
comments = 'Email sent to %s.' % form.cleaned_data['email']
prospartnerevent = ProspectivePartnerEvent(
prospartner = prospartner,
event = PROSPECTIVE_PARTNER_EVENT_EMAIL_SENT,
comments = comments,
noted_on = timezone.now(),
noted_by = request.user.contributor)
prospartnerevent.save()
if prospartner.status in [PROSPECTIVE_PARTNER_REQUESTED,
PROSPECTIVE_PARTNER_ADDED]:
prospartner.status = PROSPECTIVE_PARTNER_APPROACHED
prospartner.save()
PartnerUtils.load({'institution_name': prospartner.institution_name,
'email': form.cleaned_data['email'],
'email_subject': form.cleaned_data['email_subject'],
'message': form.cleaned_data['message'],
'include_SPB_summary': form.cleaned_data['include_SPB_summary']})
PartnerUtils.email_prospartner_generic()
messages.success(request, 'Email successfully sent')
return redirect(reverse('partners:manage'))
context = {'prospartner': prospartner, 'form': form}
return render(request, 'partners/email_prospartner_generic.html', context)
@permission_required('scipost.can_manage_SPB', return_403=True)
@transaction.atomic
......
{% if contact %}
Dear {{ contact.get_title_display }} {{ contact.last_name }}, \n\n
{% else %}
Dear colleagues, \n\n
{% endif %}
{% if message %}{{ message }}{% endif %}
{% if include_SPB_summary %}
You might by now have heard of SciPost, a recently-launched initiative aiming to bring disruptive change to current academic publishing practices.
\n\nIn summary, SciPost is a publication portal managed by professional scientists, offering (among others) high-quality Open Access journals with innovative forms of refereeing, and a means of commenting on all existing literature. SciPost is established as a not-for-profit foundation devoted to serving the interests of the international scientific community.
......@@ -19,6 +21,7 @@ You might by now have heard of SciPost, a recently-launched initiative aiming to
\n\nOn behalf of the SciPost Foundation,
\nProf. dr Jean-Sébastien Caux
\n\nJ.S.Caux@uva.nl
\nhttp://jscaux.org
\n---------------------------------------------
\nInstitute for Theoretical Physics\nUniversity of Amsterdam
......
{% load staticfiles %}
{% if contact %}
<p>Dear {{ contact.get_title_display }} {{ contact.last_name }},</p>
{% else %}
<p>Dear colleagues,</p>
{% endif %}
{% if message %}
<p>
{{ message|linebreaks }}
</p>
{% endif %}
{% if include_SPB_summary %}
<p>
You might by now have heard of SciPost, a recently-launched initiative aiming to bring disruptive change to current academic publishing practices.
......@@ -34,6 +36,8 @@ I will be happy to provide any required further details. If you are interested,
</p>
<p>On behalf of the SciPost Foundation,</p>
Prof. dr Jean-S&eacute;bastien Caux
<br/>
<br/><a href="mailto:J.S.Caux@uva.nl">J.S.Caux@uva.nl</a>
<br/><a href="http://jscaux.org">jscaux.org</a>
<br/>---------------------------------------------
<br/>Institute for Theoretical Physics
......
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