From a451c96271cf9c477b4460c05a3817390992578a Mon Sep 17 00:00:00 2001 From: Levi Date: Sat, 1 Apr 2017 17:45:12 -0500 Subject: [PATCH] changed email in alplora contact form --- alplora/views.py | 80 ++++++++++++++++++++++++------------------------ utils/forms.py | 4 +-- 2 files changed, 42 insertions(+), 42 deletions(-) diff --git a/alplora/views.py b/alplora/views.py index 8722823a..5c6bacd2 100644 --- a/alplora/views.py +++ b/alplora/views.py @@ -9,54 +9,54 @@ from django.core.urlresolvers import reverse_lazy, reverse from utils.forms import ContactUsForm class IndexView(FormView): - template_name = "alplora/index.html" - form_class = ContactUsForm - success_message = _('Message Successfully Sent') + template_name = "alplora/index.html" + form_class = ContactUsForm + success_message = _('Message Successfully Sent') - def get_context_data(self, *args, **kwargs): - context = super(IndexView, self).get_context_data(**kwargs) - languages = getlanguages() - context.update(languages) - return context + def get_context_data(self, *args, **kwargs): + context = super(IndexView, self).get_context_data(**kwargs) + languages = getlanguages() + context.update(languages) + return context - def get_success_url(self): - success_url = reverse('alplora:index') - success_url += "#requestformsuccess" - return success_url + def get_success_url(self): + success_url = reverse('alplora:index') + success_url += "#requestformsuccess" + return success_url - def form_valid(self, form): - form.save() - form.send_email() - messages.add_message(self.request, messages.SUCCESS, self.success_message) - return super(IndexView, self).form_valid(form) + def form_valid(self, form): + form.save() + form.send_email(email_to='info@alplora.ch') + messages.add_message(self.request, messages.SUCCESS, self.success_message) + return super(IndexView, self).form_valid(form) class LoginView(TemplateView): - template_name = "alplora/login.html" + template_name = "alplora/login.html" - def get_context_data(self, *args, **kwargs): - context = super(LoginView, self).get_context_data(**kwargs) - languages = getlanguages() - context.update(languages) - return context + def get_context_data(self, *args, **kwargs): + context = super(LoginView, self).get_context_data(**kwargs) + languages = getlanguages() + context.update(languages) + return context def getlanguages(): - language = get_language() - language_activate = get_language_info(language) - if language == 'de': - list_language = { - 'name': 'English', - 'code': 'en-us' - } - else: - list_language = { - 'name': 'Deutsch', - 'code': 'de' - } + language = get_language() + language_activate = get_language_info(language) + if language == 'de': + list_language = { + 'name': 'English', + 'code': 'en-us' + } + else: + list_language = { + 'name': 'Deutsch', + 'code': 'de' + } - return { - 'language': language, - 'list_language': list_language, - 'language_activate': language_activate['name_local'] - } + return { + 'language': language, + 'list_language': list_language, + 'language_activate': language_activate['name_local'] + } diff --git a/utils/forms.py b/utils/forms.py index 85c23721..dd6f7a85 100644 --- a/utils/forms.py +++ b/utils/forms.py @@ -145,10 +145,10 @@ class ContactUsForm(forms.ModelForm): 'message': _('Message'), } - def send_email(self): + def send_email(self, email_to='info@digitalglarus.ch'): text_content = render_to_string('emails/contact.txt', {'data': self.cleaned_data}) html_content = render_to_string('emails/contact.html', {'data': self.cleaned_data}) email = EmailMultiAlternatives('Subject', text_content) email.attach_alternative(html_content, "text/html") - email.to = ['info@digitalglarus.ch'] + email.to = [email_to] email.send()