Disable all saving of contact us form and send emails
This commit is contained in:
parent
9f74c0286e
commit
c5f8660c55
4 changed files with 19 additions and 18 deletions
|
@ -31,9 +31,9 @@ class ContactView(FormView):
|
|||
return context
|
||||
|
||||
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)
|
||||
#form.save()
|
||||
#form.send_email(email_to='info@alplora.ch')
|
||||
#messages.add_message(self.request, messages.SUCCESS, self.success_message)
|
||||
return render(self.request, 'alplora/contact_success.html', {})
|
||||
|
||||
|
||||
|
|
|
@ -835,9 +835,9 @@ class ContactView(FormView):
|
|||
success_message = _('Message Successfully Sent')
|
||||
|
||||
def form_valid(self, form):
|
||||
form.save()
|
||||
form.send_email()
|
||||
messages.add_message(self.request, messages.SUCCESS, self.success_message)
|
||||
#form.save()
|
||||
#form.send_email()
|
||||
#messages.add_message(self.request, messages.SUCCESS, self.success_message)
|
||||
return super(ContactView, self).form_valid(form)
|
||||
|
||||
|
||||
|
|
|
@ -25,9 +25,9 @@ class ContactView(FormView):
|
|||
success_message = _('Message Successfully Sent')
|
||||
|
||||
def form_valid(self, form):
|
||||
form.save()
|
||||
form.send_email()
|
||||
messages.add_message(self.request, messages.SUCCESS, self.success_message)
|
||||
#form.save()
|
||||
#form.send_email()
|
||||
#messages.add_message(self.request, messages.SUCCESS, self.success_message)
|
||||
return super(ContactView, self).form_valid(form)
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
|
|
|
@ -4,7 +4,7 @@ from django.core.mail import EmailMultiAlternatives
|
|||
from django.template.loader import render_to_string
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from captcha.fields import ReCaptchaField
|
||||
from django_recaptcha.fields import ReCaptchaField
|
||||
|
||||
from membership.models import CustomUser
|
||||
from .models import ContactMessage, BillingAddress, UserBillingAddress
|
||||
|
@ -209,11 +209,12 @@ class ContactUsForm(forms.ModelForm):
|
|||
}
|
||||
|
||||
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 = [email_to]
|
||||
email.send()
|
||||
pass
|
||||
#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 = [email_to]
|
||||
#email.send()
|
||||
|
|
Loading…
Reference in a new issue