def send_to_zenddesk(context): zendesk_form = IEEZendeskForm( data={ "message": context["message"], "email_address": context["email_address"], "name": context["name"], }) spam_control = helpers.SpamControl(contents=context["content"]) sender = helpers.Sender(email_address=context["email_address"]) assert zendesk_form.is_valid() if settings.DIRECTORY_FORMS_API_BASE_URL: zendesk_form.save( email_address=context["recipient_email"], form_url="/iee_contact/", service_name=context["service_name"], spam_control=spam_control, sender=sender, )
def sender(): return helpers.Sender(email_address='*****@*****.**', country_code='UK')
def process_form_data(form_list): form_data = [form.cleaned_data for form in form_list] context = { "subject": "New CHEG Enquiry", "subdomain": settings.ZENDESK_SUBDOMAIN, "IEE_GA_GTM": settings.IEE_GA_GTM } for form in form_data: """ check and store first question response in context if first response is option 3 for technical questions set context type to Zendesk """ if "location" in form.keys(): context["location"] = LOCATIONS[int(form["location"])] if context["location"] == 3: context["type"] = "Zendesk" """ check and store the second question response in context """ if "enquiry_topic" in form.keys(): context["topic"] = TOPICS[int(form["enquiry_topic"])] """ check and store the sender name, email and message in context """ if "email_address" in form.keys(): context["email_address"] = form["email_address"] if "name" in form.keys(): context["name"] = form["name"] if "message" in form.keys(): context["message"] = form["message"] if "topic" in context: if context["topic"] == TOPICS[3]: context["type"] = "email" context["recipient_email"] = settings.EU_EXIT_DIT_EMAIL context["recipient_fullname"] = settings.EU_EXIT_DIT_FULLNAME context["service_name"] = settings.ZENDESK_EU_EXIT_SERVICE_NAME elif context["topic"] == TOPICS[4]: context["type"] = "Zendesk" context["recipient_email"] = settings.EU_EXIT_EMAIL context["recipient_fullname"] = settings.EU_EXIT_FULLNAME context["service_name"] = settings.ZENDESK_EU_EXIT_SERVICE_NAME else: context["type"] = "Zendesk" context["recipient_email"] = settings.FEEDBACK_EMAIL context["recipient_fullname"] = settings.FEEDBACK_FULLNAME context["service_name"] = settings.ZENDESK_CHEG_SERVICE_NAME template = get_template("contact/contact_message_tmpl.txt") context["content"] = template.render(context) context["spam_control"] = helpers.SpamControl( contents=context["content"]) context["sender"] = helpers.Sender( country_code="", email_address=[context["email_address"]]) context[ "form_url"] = "http://contact.check-duties-customs-exporting-goods.service.gov.uk/" return context
def sender(): return helpers.Sender( email_address='*****@*****.**', country_code='UK', ip_address='192.168.0.1', )
def process_form_data(self, form_list, form_path): form_data = self.get_all_cleaned_data() is_feedback = ( True if form_path == "/feedback/" or form_data["category"] == "2" else False ) country_code = self.request.session["origin_country"] country_code = country_code.upper() context = { "country_code": country_code, "service_name": settings.SERVICE_NAME, "location": Country.objects.get(country_code=country_code).name, "email_address": form_data["email_address"], "name": form_data["name"], "message": form_data["message"], "form_url": form_path, } if is_feedback: context["type"] = "Zendesk" context["recipient_email"] = settings.FEEDBACK_EMAIL context["recipient_fullname"] = settings.FEEDBACK_CONTACT if is_feedback: if "category" not in form_data.keys(): context["subject"] = settings.FEEDBACK_SUBJECT else: context["subject"] = settings.SUPPORT_SUBJECT else: context["subject"] = settings.CONTACT_SUBJECT if "category" in form_data.keys(): context["category"] = CATEGORIES[int(form_data["category"])] if "topic" in form_data.keys(): context["topic"] = TOPICS[int(form_data["topic"])] if form_data["topic"] == "2": # Importing animals, plants or food, environmental regulations, # sanitary and phytosanitary regulations context["type"] = "Email" context["recipient_email"] = settings.DEFRA_EMAIL context["recipient_fullname"] = settings.DEFRA_CONTACT elif form_data["topic"] == "3": # Product safety and standards, packaging and labelling context["type"] = "Email" context["recipient_email"] = settings.BEIS_EMAIL context["recipient_fullname"] = settings.BEIS_CONTACT elif form_data["topic"] == "4": # Topic: Import controls, trade agreements, rules of origin context["type"] = "Zendesk" context["subject"] += settings.DDAT_SUBJECT_SUFFIX context["subdomain"] = settings.DIT_SUBDOMAIN context["recipient_fullname"] = settings.DDAT_CONTACT elif form_data["topic"] == "5": # Other context["type"] = "Zendesk" context["subject"] += settings.DIT_SUBJECT_SUFFIX context["recipient_fullname"] = settings.DIT_CONTACT context["subdomain"] = ( settings.DIT_SUBDOMAIN if context["type"] == "Zendesk" else "" ) msg_tmpl = ( "contact/feedback_message_tmpl.txt" if is_feedback else "contact/contact_message_tmpl.txt" ) template = get_template(msg_tmpl) context["content"] = template.render(context) context["spam_control"] = helpers.SpamControl(contents=context["content"]) context["sender"] = helpers.Sender( country_code=context["country_code"], email_address=context["email_address"] ) return context