Disable all saving of contact us form and send emails

This commit is contained in:
app@dynamicweb-production 2023-11-17 03:29:10 +01:00
parent 9f74c0286e
commit c5f8660c55
4 changed files with 19 additions and 18 deletions

View file

@ -31,9 +31,9 @@ class ContactView(FormView):
return context return context
def form_valid(self, form): def form_valid(self, form):
form.save() #form.save()
form.send_email(email_to='info@alplora.ch') #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 render(self.request, 'alplora/contact_success.html', {}) return render(self.request, 'alplora/contact_success.html', {})

View file

@ -835,9 +835,9 @@ class ContactView(FormView):
success_message = _('Message Successfully Sent') success_message = _('Message Successfully Sent')
def form_valid(self, form): def form_valid(self, form):
form.save() #form.save()
form.send_email() #form.send_email()
messages.add_message(self.request, messages.SUCCESS, self.success_message) #messages.add_message(self.request, messages.SUCCESS, self.success_message)
return super(ContactView, self).form_valid(form) return super(ContactView, self).form_valid(form)

View file

@ -25,9 +25,9 @@ class ContactView(FormView):
success_message = _('Message Successfully Sent') success_message = _('Message Successfully Sent')
def form_valid(self, form): def form_valid(self, form):
form.save() #form.save()
form.send_email() #form.send_email()
messages.add_message(self.request, messages.SUCCESS, self.success_message) #messages.add_message(self.request, messages.SUCCESS, self.success_message)
return super(ContactView, self).form_valid(form) return super(ContactView, self).form_valid(form)
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):

View file

@ -4,7 +4,7 @@ from django.core.mail import EmailMultiAlternatives
from django.template.loader import render_to_string from django.template.loader import render_to_string
from django.utils.translation import ugettext_lazy as _ 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 membership.models import CustomUser
from .models import ContactMessage, BillingAddress, UserBillingAddress from .models import ContactMessage, BillingAddress, UserBillingAddress
@ -209,11 +209,12 @@ class ContactUsForm(forms.ModelForm):
} }
def send_email(self, email_to='info@digitalglarus.ch'): def send_email(self, email_to='info@digitalglarus.ch'):
text_content = render_to_string( pass
'emails/contact.txt', {'data': self.cleaned_data}) #text_content = render_to_string(
html_content = render_to_string( # 'emails/contact.txt', {'data': self.cleaned_data})
'emails/contact.html', {'data': self.cleaned_data}) #html_content = render_to_string(
email = EmailMultiAlternatives('Subject', text_content) # 'emails/contact.html', {'data': self.cleaned_data})
email.attach_alternative(html_content, "text/html") #email = EmailMultiAlternatives('Subject', text_content)
email.to = [email_to] #email.attach_alternative(html_content, "text/html")
email.send() #email.to = [email_to]
#email.send()