From 7410a73e60a0624df65e22eefb382769757a45fa Mon Sep 17 00:00:00 2001 From: Arvind Tiwari Date: Wed, 11 Oct 2017 00:36:17 +0530 Subject: [PATCH] from email removed direct dependency from post request --- datacenterlight/views.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/datacenterlight/views.py b/datacenterlight/views.py index c95b1b2b..88a8f2d9 100644 --- a/datacenterlight/views.py +++ b/datacenterlight/views.py @@ -49,15 +49,18 @@ class ContactUsView(FormView): def form_valid(self, form): form.save() + from_emails = { + 'glasfaser': 'glasfaser@ungleich.ch' + } + from_page = self.request.POST.get('from_page') + print(from_emails.get(from_page, 'info@ungleich.ch')) email_data = { 'subject': "{dcl_text} Message from {sender}".format( dcl_text=settings.DCL_TEXT, sender=form.cleaned_data.get('email') ), 'from_email': settings.DCL_SUPPORT_FROM_ADDRESS, - 'to': '{}@ungleich.ch'.format( - self.request.POST.get('from_page', 'info') - ), + 'to': from_emails.get(from_page, 'info@ungleich.ch'), 'body': "\n".join( ["%s=%s" % (k, v) for (k, v) in form.cleaned_data.items()]), 'reply_to': [form.cleaned_data.get('email')],