Merge pull request #188 from levivm/feature/new_digitalglarus

changed email in alplora contact form
This commit is contained in:
Levi Velázquez 2017-04-01 17:46:00 -05:00 committed by GitHub
commit 40edb3f006
2 changed files with 42 additions and 42 deletions

View file

@ -9,54 +9,54 @@ from django.core.urlresolvers import reverse_lazy, reverse
from utils.forms import ContactUsForm from utils.forms import ContactUsForm
class IndexView(FormView): class IndexView(FormView):
template_name = "alplora/index.html" template_name = "alplora/index.html"
form_class = ContactUsForm form_class = ContactUsForm
success_message = _('Message Successfully Sent') success_message = _('Message Successfully Sent')
def get_context_data(self, *args, **kwargs): def get_context_data(self, *args, **kwargs):
context = super(IndexView, self).get_context_data(**kwargs) context = super(IndexView, self).get_context_data(**kwargs)
languages = getlanguages() languages = getlanguages()
context.update(languages) context.update(languages)
return context return context
def get_success_url(self): def get_success_url(self):
success_url = reverse('alplora:index') success_url = reverse('alplora:index')
success_url += "#requestformsuccess" success_url += "#requestformsuccess"
return success_url return success_url
def form_valid(self, form): def form_valid(self, form):
form.save() form.save()
form.send_email() form.send_email(email_to='info@alplora.ch')
messages.add_message(self.request, messages.SUCCESS, self.success_message) messages.add_message(self.request, messages.SUCCESS, self.success_message)
return super(IndexView, self).form_valid(form) return super(IndexView, self).form_valid(form)
class LoginView(TemplateView): class LoginView(TemplateView):
template_name = "alplora/login.html" template_name = "alplora/login.html"
def get_context_data(self, *args, **kwargs): def get_context_data(self, *args, **kwargs):
context = super(LoginView, self).get_context_data(**kwargs) context = super(LoginView, self).get_context_data(**kwargs)
languages = getlanguages() languages = getlanguages()
context.update(languages) context.update(languages)
return context return context
def getlanguages(): def getlanguages():
language = get_language() language = get_language()
language_activate = get_language_info(language) language_activate = get_language_info(language)
if language == 'de': if language == 'de':
list_language = { list_language = {
'name': 'English', 'name': 'English',
'code': 'en-us' 'code': 'en-us'
} }
else: else:
list_language = { list_language = {
'name': 'Deutsch', 'name': 'Deutsch',
'code': 'de' 'code': 'de'
} }
return { return {
'language': language, 'language': language,
'list_language': list_language, 'list_language': list_language,
'language_activate': language_activate['name_local'] 'language_activate': language_activate['name_local']
} }

View file

@ -145,10 +145,10 @@ class ContactUsForm(forms.ModelForm):
'message': _('Message'), '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}) text_content = render_to_string('emails/contact.txt', {'data': self.cleaned_data})
html_content = render_to_string('emails/contact.html', {'data': self.cleaned_data}) html_content = render_to_string('emails/contact.html', {'data': self.cleaned_data})
email = EmailMultiAlternatives('Subject', text_content) email = EmailMultiAlternatives('Subject', text_content)
email.attach_alternative(html_content, "text/html") email.attach_alternative(html_content, "text/html")
email.to = ['info@digitalglarus.ch'] email.to = [email_to]
email.send() email.send()