diff --git a/partners/forms.py b/partners/forms.py index 1288e96d835f7fb86d1916b624f76c0f90876314..77dd8dec8a116b110c9ac232bb791f966dd64ea6 100644 --- a/partners/forms.py +++ b/partners/forms.py @@ -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): diff --git a/partners/templates/partners/_prospective_partner_card.html b/partners/templates/partners/_prospective_partner_card.html index 5496f483c4504fa5c1916c9abef54c4e34111f8b..afc724dbb9cc95e4169abe887e151539247b3eb6 100644 --- a/partners/templates/partners/_prospective_partner_card.html +++ b/partners/templates/partners/_prospective_partner_card.html @@ -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"> diff --git a/partners/templates/partners/email_prospartner_generic.html b/partners/templates/partners/email_prospartner_generic.html new file mode 100644 index 0000000000000000000000000000000000000000..6732aa816ef9eb0ffc243267a11102538add437f --- /dev/null +++ b/partners/templates/partners/email_prospartner_generic.html @@ -0,0 +1,29 @@ +{% 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 %} diff --git a/partners/urls.py b/partners/urls.py index ed50ba7595ef25515bfe6da02467211056449627..f65a3551cd5a9e3c5b9d32eb9c9c3763064489d3 100644 --- a/partners/urls.py +++ b/partners/urls.py @@ -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'), ] diff --git a/partners/utils.py b/partners/utils.py index fc40882c002bf695b7e219a08a302faf44e966f0..aade17e1d2c1dbfdd0aff7514143520f55946954 100644 --- a/partners/utils.py +++ b/partners/utils.py @@ -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']) diff --git a/partners/views.py b/partners/views.py index 111dda8d8190b60812b4991328984d0519ee8984..2117ae87f45e1834ee7b62e0cc4d22b960241e65 100644 --- a/partners/views.py +++ b/partners/views.py @@ -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 diff --git a/templates/email/email_prospartner_contact.html b/templates/email/email_prospartner_contact.html index 99233055e4eee8ea76cfdaaf64dbeec41c7ad186..5f0455f8b1f0420e757364b23bc35ca5ac90a31c 100644 --- a/templates/email/email_prospartner_contact.html +++ b/templates/email/email_prospartner_contact.html @@ -1,7 +1,9 @@ +{% 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 diff --git a/templates/email/email_prospartner_contact_html.html b/templates/email/email_prospartner_contact_html.html index 9d801a150d52819876451f7d7a6cd8253e9f9060..9a66c2f9d81a02102af05d04af138a7612df739d 100644 --- a/templates/email/email_prospartner_contact_html.html +++ b/templates/email/email_prospartner_contact_html.html @@ -1,12 +1,14 @@ {% 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é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