Commit 78095b4e authored by Patrick Kimber's avatar Patrick Kimber

Convert the created time to 'localtime' for the email subject

https://www.kbsoftware.co.uk/crm/ticket/3562/
parent f7cf57ce
Pipeline #30519155 passed with stage
in 1 minute and 31 seconds
......@@ -4,6 +4,7 @@ import logging
from captcha.fields import ReCaptchaField
from django import forms
from django.urls import reverse
from django.utils import timezone
from base.form_utils import RequiredFieldForm
from gdpr.models import UserConsent
......@@ -19,6 +20,7 @@ logger = logging.getLogger(__name__)
class EnquiryForm(RequiredFieldForm):
"""user is not logged in... so we need a captcha."""
captcha = ReCaptchaField()
consent_checkbox = forms.BooleanField(required=False)
......@@ -47,7 +49,7 @@ class EnquiryForm(RequiredFieldForm):
def _email_message(self, enquiry):
result = "{} - enquiry received from {}, ".format(
enquiry.created.strftime("%d/%m/%Y %H:%M"), enquiry.name
self._email_time(enquiry), enquiry.name
)
if enquiry.email:
result = result + "{} ".format(enquiry.email)
......@@ -62,6 +64,10 @@ class EnquiryForm(RequiredFieldForm):
def _email_subject(self, instance):
return "Enquiry from {}".format(instance.name)
def _email_time(self, enquiry):
x = timezone.localtime(enquiry.created)
return x.strftime("%d/%m/%Y %H:%M")
def clean_consent_checkbox(self):
data = self.cleaned_data.get("consent_checkbox")
if not data:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment