Merge branch 'master' into 12224-change-ch-vat

This commit is contained in:
pcoder116 2023-12-06 10:14:28 +00:00
commit a38a4a86a4
6 changed files with 45 additions and 34 deletions

View file

@ -31,9 +31,10 @@ 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)
print("alplora contactusform")
#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', {})

View file

@ -63,23 +63,23 @@ class ContactUsView(FormView):
)
def form_valid(self, form):
form.save()
from_emails = {
'glasfaser': 'glasfaser@ungleich.ch'
}
from_page = self.request.POST.get('from_page')
email_data = {
'subject': "{dcl_text} Message from {sender}".format(
dcl_text=settings.DCL_TEXT,
sender=form.cleaned_data.get('email')
),
'from_email': settings.DCL_SUPPORT_FROM_ADDRESS,
'to': [from_emails.get(from_page, 'support@ungleich.ch')],
'body': "\n".join(
["%s=%s" % (k, v) for (k, v) in form.cleaned_data.items()]),
'reply_to': [form.cleaned_data.get('email')],
}
send_plain_email_task.delay(email_data)
#form.save()
#from_emails = {
# 'glasfaser': 'glasfaser@ungleich.ch'
#}
#from_page = self.request.POST.get('from_page')
#email_data = {
# 'subject': "{dcl_text} Message from {sender}".format(
# dcl_text=settings.DCL_TEXT,
# sender=form.cleaned_data.get('email')
# ),
# 'from_email': settings.DCL_SUPPORT_FROM_ADDRESS,
# 'to': [from_emails.get(from_page, 'support@ungleich.ch')],
# 'body': "\n".join(
# ["%s=%s" % (k, v) for (k, v) in form.cleaned_data.items()]),
# 'reply_to': [form.cleaned_data.get('email')],
#}
#send_plain_email_task.delay(email_data)
if self.request.is_ajax():
return self.render_to_response(
self.get_context_data(success=True, contact_form=form))

View file

@ -835,9 +835,10 @@ 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)
print("digital glarus contactusform")
#form.save()
#form.send_email()
#messages.add_message(self.request, messages.SUCCESS, self.success_message)
return super(ContactView, self).form_valid(form)

View file

@ -56,6 +56,9 @@ dotenv.load_dotenv("{0}/.env".format(PROJECT_DIR))
from multisite import SiteID
RECAPTCHA_PUBLIC_KEY = env('RECAPTCHA_PUBLIC_KEY')
RECAPTCHA_PRIVATE_KEY = env('RECAPTCHA_PRIVATE_KEY')
UNGLEICH_BLOG_SITE_ID = int_env("UNGLEICH_BLOG_SITE_ID")
SITE_ID = SiteID(default=(UNGLEICH_BLOG_SITE_ID if
UNGLEICH_BLOG_SITE_ID > 0 else 1))
@ -125,6 +128,7 @@ INSTALLED_APPS = (
'djangocms_file',
'djangocms_picture',
'djangocms_video',
'django_recaptcha',
# 'djangocms_flash',
# 'djangocms_googlemap',
# 'djangocms_inherit',

View file

@ -25,9 +25,10 @@ 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)
print("ungleich_page contactusform")
#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):

View file

@ -4,6 +4,8 @@ from django.core.mail import EmailMultiAlternatives
from django.template.loader import render_to_string
from django.utils.translation import ugettext_lazy as _
from django_recaptcha.fields import ReCaptchaField
from membership.models import CustomUser
from .models import ContactMessage, BillingAddress, UserBillingAddress
@ -188,6 +190,7 @@ class UserBillingAddressForm(forms.ModelForm):
class ContactUsForm(forms.ModelForm):
error_css_class = 'autofocus'
captcha = ReCaptchaField()
class Meta:
model = ContactMessage
@ -206,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()