changed email in alplora contact form
This commit is contained in:
parent
25e3b7e888
commit
a451c96271
2 changed files with 42 additions and 42 deletions
|
@ -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']
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in a new issue