def done(self, form_list, **kwargs): form_data = self.serialize_form_list(form_list) sender = Sender( email_address=form_data['email'], country_code=None, ip_address=helpers.get_sender_ip_address(self.request), ) action = actions.ZendeskAction( subject='ERP form was submitted', full_name=form_data['given_name'] + ' ' + form_data['family_name'], service_name=constants.ZENDESK_SERVICE_NAME, subdomain=settings.ERP_ZENDESK_SUBDOMAIN, email_address=form_data['email'], form_url=self.get_step_url(constants.STEP_SUMMARY), form_session=self.form_session, sender=sender, ) response = action.save(form_data) if response.status_code == 429: # user has been rate limited for submitting too many. don't tell them. pass else: response.raise_for_status() template_name = self.templates[constants.STEP_FINISHED] context = self.get_context_data(form=None) context['summary'], context['form_values'] = self.get_summary() context['summary_template'] = self.summary_template return TemplateResponse(self.request, [template_name], context)
def done(self, form_list, **kwargs): form_data = self.serialize_form_list(form_list) sender = Sender( email_address=form_data['contact_email'], country_code=None ) full_name = ('%s %s' % ( form_data['contact_first_name'], form_data['contact_last_name'] )).strip() action = actions.ZendeskAction( subject=settings.CONTACT_SOO_ZENDESK_SUBJECT, full_name=full_name, email_address=form_data['contact_email'], service_name='soo', form_url=reverse( 'contact-us-soo', kwargs={'step': 'contact-details'} ), form_session=self.form_session, sender=sender, ) response = action.save(form_data) response.raise_for_status() self.request.session.pop(SESSION_KEY_SOO_MARKET, None) self.set_form_data_cache(form_data) return redirect(self.success_url)
def test_zendesk_action_mixin_action_class_subdomain(settings, form_session, spam_control, sender): mock_client = mock.Mock(spec_set=client.APIFormsClient) action = actions.ZendeskAction( client=mock_client, subject='a subject', full_name='jim example', email_address='*****@*****.**', service_name='some service', subdomain='some-sobdomain', form_url='/the/form/', form_session=form_session, spam_control=spam_control, sender=sender, ) action.save({'requester_email': '*****@*****.**', 'field_two': 'value two'}) assert mock_client.submit_generic.call_count == 1 assert mock_client.submit_generic.call_args == mock.call({ 'data': { 'requester_email': '*****@*****.**', 'field_two': 'value two' }, 'meta': { 'action_name': 'zendesk', 'subject': 'a subject', 'full_name': 'jim example', 'email_address': '*****@*****.**', 'subdomain': 'some-sobdomain', 'service_name': 'some service', 'form_url': '/the/form/', 'funnel_steps': ['one', 'two'], 'ingress_url': 'example.com', 'sender': { 'email_address': '*****@*****.**', 'country_code': 'UK', 'ip_address': '192.168.0.1', }, 'spam_control': { 'contents': ['hello buy my goods'], } } })
def done(self, form_list, **kwargs): form_data = self.serialize_form_list(form_list) sender = Sender( email_address=form_data['email'], country_code=None, ) action = actions.ZendeskAction( subject='ERP form was submitted', full_name=form_data['given_name'] + ' ' + form_data['family_name'], service_name='erp', email_address=form_data['email'], form_url=reverse('wizard', kwargs={'step': TYPE}), form_session=self.form_session, sender=sender, ) response = action.save(form_data) response.raise_for_status() return redirect(self.success_url)
def done(self, form_list, form_dict, **kwargs): data = self.serialize_form_list(form_list) subject = (f"{settings.MARKET_ACCESS_ZENDESK_SUBJECT}: " f"{data['country']}: " f"{data['company_name']}") sender = Sender(email_address=data['email'], country_code=None) action = actions.ZendeskAction( email_address=data['email'], full_name=f"{data['firstname']} {data['lastname']}", subject=subject, service_name=settings.MARKET_ACCESS_FORMS_API_ZENDESK_SEVICE_NAME, form_url=reverse('report-ma-barrier', kwargs={'step': 'about'}), sender=sender, ) response = action.save(data) response.raise_for_status() context = {'all_cleaned_data': self.get_all_cleaned_data()} return TemplateResponse(self.request, self.templates['finished'], context)