Exemple #1
0
 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 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)
Exemple #3
0
 def send_agent_email(self, form_url):
     sender = Sender(email_address=self.cleaned_data['email_address'],
                     country_code=self.cleaned_data['country'])
     action = self.action_class(
         template_id=settings.HPO_GOV_NOTIFY_AGENT_TEMPLATE_ID,
         email_address=settings.HPO_GOV_NOTIFY_AGENT_EMAIL_ADDRESS,
         form_url=form_url,
         sender=sender,
     )
     response = action.save(self.serialized_data)
     response.raise_for_status()
Exemple #4
0
 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 = PardotAction(
         pardot_url=settings.UKEF_FORM_SUBMIT_TRACKER_URL,
         form_url=reverse('uk-export-finance-lead-generation-form',
                          kwargs={'step': self.CATEGORY}),
         sender=sender,
     )
     response = action.save(form_data)
     response.raise_for_status()
     return redirect(self.success_url)
 def send_agent_message(self, form):
     sender = Sender(
         email_address=form.cleaned_data['email'],
         country_code=None,
     )
     response = form.save(
         template_id=self.notify_settings.agent_template,
         email_address=self.notify_settings.agent_email,
         form_url=self.request.get_full_path(),
         form_session=self.form_session,
         sender=sender,
     )
     response.raise_for_status()
Exemple #6
0
 def form_valid(self, form):
     sender = Sender(
         email_address=form.cleaned_data['email'],
         country_code=None,
     )
     response = form.save(
         template_id=settings.EXPORT_VOUCHERS_GOV_NOTIFY_TEMPLATE_ID,
         email_address=settings.EXPORT_VOUCHERS_AGENT_EMAIL,
         form_url=self.request.get_full_path(),
         form_session=self.form_session,
         sender=sender,
     )
     response.raise_for_status()
     return super().form_valid(form)
Exemple #7
0
 def send_support_message(self, form):
     location = helpers.get_location(self.request)
     sender = Sender(
         email_address=form.cleaned_data['email'],
         country_code=location.get('country') if location else None,
         ip_address=helpers.get_sender_ip_address(self.request),
     )
     response = form.save(
         template_id=settings.CONTACTUS_ENQURIES_SUPPORT_TEMPLATE_ID,
         email_address=settings.GREAT_SUPPORT_EMAIL,
         form_url=self.request.get_full_path(),
         sender=sender,
     )
     response.raise_for_status()
 def form_valid(self, form):
     sender = Sender(
         email_address=form.cleaned_data['email'],
         country_code=None,
     )
     response = form.save(
         email_address=form.cleaned_data['email'],
         full_name=form.full_name,
         subject=self.subject,
         service_name=settings.DIRECTORY_FORMS_API_ZENDESK_SEVICE_NAME,
         form_url=self.request.get_full_path(),
         form_session=self.form_session,
         sender=sender)
     response.raise_for_status()
     return super().form_valid(form)
 def form_valid(self, form):
     sender = Sender(
         email_address=form.cleaned_data['email'],
         country_code=form.cleaned_data.get('country_name'),
     )
     response = form.save(
         subject=self.subject,
         full_name=form.full_name,
         email_address=form.cleaned_data['email'],
         service_name='eu_exit',
         subdomain=settings.EU_EXIT_ZENDESK_SUBDOMAIN,
         form_url=self.request.path,
         sender=sender,
     )
     response.raise_for_status()
     return super().form_valid(form)
Exemple #10
0
 def send_agent_email(self):
     sender = Sender(email_address=self.cleaned_data['email'],
                     country_code=self.cleaned_data['country'])
     action = self.action_class(
         recipients=[settings.IIGB_AGENT_EMAIL],
         subject='Contact form agent email subject',
         reply_to=[settings.DEFAULT_FROM_EMAIL],
         form_url=self.submission_url,
         sender=sender,
     )
     response = action.save({
         'text_body':
         self.render_email('email/email_agent.txt'),
         'html_body':
         self.render_email('email/email_agent.html'),
     })
     response.raise_for_status()
 def send_agent_message(self, form_data):
     sender = Sender(email_address=form_data['email'], country_code=None)
     action = actions.EmailAction(
         recipients=[form_data['region_office_email']],
         subject=settings.CONTACT_EXPORTING_AGENT_SUBJECT,
         reply_to=[settings.DEFAULT_FROM_EMAIL],
         form_url=reverse(
             'contact-us-export-advice', kwargs={'step': 'comment'}
         ),
         form_session=self.form_session,
         sender=sender,
     )
     template_name = 'contact/exporting-from-uk-agent-email.html'
     html = render_to_string(template_name, {'form_data': form_data})
     response = action.save(
         {'text_body': strip_tags(html), 'html_body': html}
     )
     response.raise_for_status()
Exemple #12
0
    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 test_export_voucher_submit(mock_gov_notify_action, mock_form_session_class,
                               client, captcha_stub):
    url = reverse('export-voucher-form')
    data = {
        'company_name': 'Example corp',
        'companies_house_number': '012345678',
        'first_name': 'Jim',
        'last_name': 'Example',
        'email': '*****@*****.**',
        'exported_to_eu': True,
        'g-recaptcha-response': captcha_stub,
        'terms_agreed': True,
    }
    response = client.post(url, data=data)

    assert response.status_code == 302
    assert response.url == reverse('export-voucher-success')
    assert mock_gov_notify_action.call_count == 1
    assert mock_gov_notify_action.call_args == mock.call(
        template_id=settings.EXPORT_VOUCHERS_GOV_NOTIFY_TEMPLATE_ID,
        email_address=settings.EXPORT_VOUCHERS_AGENT_EMAIL,
        form_url=reverse('export-voucher-form'),
        form_session=mock_form_session_class(),
        sender=Sender(email_address=data['email'],
                      country_code=None,
                      ip_address=None),
    )
    assert mock_gov_notify_action().save.call_count == 1
    assert mock_gov_notify_action().save.call_args == mock.call({
        'company_name':
        data['company_name'],
        'companies_house_number':
        data['companies_house_number'],
        'first_name':
        data['first_name'],
        'last_name':
        data['last_name'],
        'email':
        data['email'],
        'exported_to_eu':
        data['exported_to_eu'],
    })
Exemple #14
0
    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)