From 75e7901aa5cee29d0267473a863a116f7162bbeb Mon Sep 17 00:00:00 2001 From: "J.-S. Caux" <J.S.Caux@uva.nl> Date: Mon, 3 Oct 2016 21:53:22 +0200 Subject: [PATCH] Include choice of from address in precooked email --- scipost/forms.py | 5 +++++ scipost/models.py | 5 +++++ scipost/views.py | 3 ++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/scipost/forms.py b/scipost/forms.py index 66f64f20c..21585bae2 100644 --- a/scipost/forms.py +++ b/scipost/forms.py @@ -198,6 +198,11 @@ class SendPrecookedEmailForm(forms.Form): include_scipost_summary = forms.BooleanField( required=False, initial=False, label='Include SciPost summary at end of message') + from_address = forms.ChoiceField(choices=SCIPOST_FROM_ADDRESSES) + + # def __init__(self, *args, **kwards): + # super(SendPrecookedEmailForm, self).__init__(*args, **kwargs) + # self.fields['from_address'].widget.attrs.update( class CreateListForm(forms.ModelForm): diff --git a/scipost/models.py b/scipost/models.py index dc487a81d..93c603dbf 100644 --- a/scipost/models.py +++ b/scipost/models.py @@ -499,6 +499,11 @@ class AuthorshipClaim(models.Model): # email = models.EmailField() +SCIPOST_FROM_ADDRESSES = ( + ('J.-S. Caux', 'J.-S. Caux <jscaux@scipost.org>'), + ('Admin', 'SciPost Admin <admin@scipost.org>'), +) + class PrecookedEmail(models.Model): """ Each instance contains an email template in both plain and html formats. diff --git a/scipost/views.py b/scipost/views.py index 73db3faca..c64051e34 100644 --- a/scipost/views.py +++ b/scipost/views.py @@ -1128,7 +1128,8 @@ def send_precooked_email(request): html_version = html_template.render(email_context) message = EmailMultiAlternatives( precookedEmail.email_subject, - email_text, 'SciPost Admin <admin@scipost.org>', + #email_text, 'SciPost Admin <admin@scipost.org>', + email_text, form.cleaned_data['from_address'], [form.cleaned_data['email_address']], bcc=['admin@scipost.org']) message.attach_alternative(html_version, 'text/html') -- GitLab