class PersonalDetailsForm(forms.Form): first_name = fields.CharField(label='First name') last_name = fields.CharField(label='Last name') position = fields.CharField(label='Position in organisation') email = fields.EmailField(label='Email address') phone = fields.CharField(label='Phone')
class InternationalContactForm(SerializeDataMixin, GovNotifyActionMixin, forms.Form): ORGANISATION_TYPE_CHOICES = ( ('COMPANY', 'Company'), ('OTHER', 'Other type of organisation'), ) given_name = fields.CharField(validators=anti_phising_validators) family_name = fields.CharField(validators=anti_phising_validators) email = fields.EmailField(label='Email address') organisation_type = fields.ChoiceField(label_suffix='', widget=widgets.RadioSelect(), choices=ORGANISATION_TYPE_CHOICES) organisation_name = fields.CharField( label='Your organisation name', validators=anti_phising_validators, ) country_name = fields.ChoiceField(choices=[('', 'Please select')] + choices.COUNTRY_CHOICES, ) city = fields.CharField(label='City', validators=anti_phising_validators) comment = fields.CharField(label='Tell us how we can help', widget=Textarea, validators=anti_phising_validators) captcha = ReCaptchaField( label='', label_suffix='', ) terms_agreed = fields.BooleanField(label=TERMS_LABEL)
class LeadGenerationForm(ZendeskActionMixin, forms.Form): error_css_class = 'input-field-container has-error' PLEASE_SELECT_LABEL = _('Please select an industry') TERMS_CONDITIONS_MESSAGE = _( 'Tick the box to confirm you agree to the terms and conditions.') full_name = fields.CharField(label=_('Your name')) email_address = fields.EmailField(label=_('Email address')) company_name = fields.CharField(label=_('Organisation name')) country = fields.CharField(label=_('Country')) comment = fields.CharField(label=_('Describe what you need'), help_text=_('Maximum 1000 characters.'), max_length=1000, widget=Textarea, validators=[no_html, not_contains_url_or_email]) terms = fields.BooleanField( error_messages={'required': TERMS_CONDITIONS_MESSAGE}) captcha = ReCaptchaField( label='', label_suffix='', ) @property def serialized_data(self): # this data will be sent to zendesk. `captcha` and `terms_agreed` are # not useful to the zendesk user as those fields have to be present # for the form to be submitted. data = self.cleaned_data.copy() del data['captcha'] del data['terms'] return data
class UserAccount(forms.Form): PASSWORD_HELP_TEXT = ('<p>Your password must:</p>' '<ul class="list list-bullet">' '<li>be at least 10 characters</li>' '<li>contain at least one letter</li>' '<li>contain at least one number</li>' '<li>not contain the word "password"</li>' '</ul>') MESSAGE_NOT_MATCH = "Passwords don't match" email = fields.EmailField(label='Your email') password = fields.CharField(help_text=mark_safe(PASSWORD_HELP_TEXT), widget=PasswordInput) password_confirmed = fields.CharField( label='Confirm password', widget=PasswordInput, ) captcha = ReCaptchaField( label='', label_suffix='', ) terms_agreed = fields.BooleanField(label=mark_safe( 'Tick this box to accept the ' f'<a href="{urls.TERMS_AND_CONDITIONS}" target="_blank">terms and ' 'conditions</a> of the great.gov.uk service.')) def clean_password_confirmed(self): value = self.cleaned_data['password_confirmed'] if value != self.cleaned_data['password']: raise ValidationError(self.MESSAGE_NOT_MATCH) return value
class BaseShortForm(forms.Form): comment = fields.CharField( label='Please give us as much detail as you can', widget=Textarea, validators=anti_phising_validators) given_name = fields.CharField( label='First name', validators=anti_phising_validators, ) family_name = fields.CharField(label='Last name', validators=anti_phising_validators) email = fields.EmailField() company_type = fields.ChoiceField( label_suffix='', widget=widgets.RadioSelect(), choices=COMPANY_TYPE_CHOICES, ) company_type_other = fields.ChoiceField( label='Type of organisation', label_suffix='', choices=(('', 'Please select'), ) + COMPANY_TYPE_OTHER_CHOICES, required=False, ) organisation_name = fields.CharField(validators=anti_phising_validators) postcode = fields.CharField(validators=anti_phising_validators) captcha = ReCaptchaField( label='', label_suffix='', ) terms_agreed = fields.BooleanField(label=TERMS_LABEL)
class PersonalDetailsForm(forms.Form): error_css_class = 'input-field-container has-error' firstname = fields.CharField(label='Your first name') lastname = fields.CharField(label='Your last name') position = fields.CharField(label='Position in company') email = fields.EmailField(label='Email address') phone = fields.CharField(label='Phone')
class PIRForm(forms.Form): name = fields.CharField( required=True, label=_('Name'), ) company = fields.CharField( required=True, label=_('Company'), ) email = fields.EmailField( required=True, label=_('Email'), ) phone_number = fields.CharField( required=False, label=_('Phone number (optional)'), widget=TextInput(attrs={'type': 'tel'}) ) country = fields.ChoiceField( required=True, label=_('Country'), choices=sorted( [(k, v) for k, v in COUNTRIES.items()], key=lambda tup: tup[1] ) ) gdpr_optin = fields.BooleanField(initial=False, required=False) def __init__(self, *args, **kwargs): super(PIRForm, self).__init__(*args, **kwargs) self.client = PIRAPIClient( base_url=settings.PIR_API_URL, api_key=settings.PIR_API_KEY ) options = self.client.get_options() sector_choices = [ ( o['value'], o['display_name']) for o in options['sector']['choices'] ] self.fields['sector'] = fields.ChoiceField( label='Sector', choices=sector_choices ) self.fields['captcha'] = NoReCaptchaField()
class SellingOnlineOverseasContactDetails(forms.Form): contact_name = fields.CharField(validators=anti_phising_validators) contact_email = fields.EmailField(label='Email address') phone = fields.CharField(label='Telephone number') email_pref = fields.BooleanField( label='I prefer to be contacted by email', required=False, ) captcha = ReCaptchaField( label='', label_suffix='', ) terms_agreed = fields.BooleanField(label=TERMS_LABEL)
class AboutForm(forms.Form): error_css_class = 'input-field-container has-error' CATEGORY_CHOICES = ('I’m an exporter or I want to export', 'I work for a trade association', 'Other') firstname = fields.CharField( label='First name', error_messages={'required': 'Enter your first name'}) lastname = fields.CharField( label='Last name', error_messages={'required': 'Enter your last name'}) jobtitle = fields.CharField( label='Job title', error_messages={'required': 'Enter your job title'}) categories = fields.ChoiceField( label='Business type', widget=widgets.RadioSelect( attrs={'id': 'checkbox-single'}, use_nice_ids=True, ), choices=((choice, choice) for choice in CATEGORY_CHOICES), error_messages={'required': 'Tell us your business type'}) organisation_description = fields.CharField( label='Tell us about your organisation', widget=TextInput(attrs={'class': 'js-field-other'}), required=False) company_name = fields.CharField( label='Business or organisation name', error_messages={ 'required': 'Enter your business or organisation name' }) email = fields.EmailField( label='Email address', error_messages={'required': 'Enter your email address'}) phone = fields.CharField( label='Telephone number', error_messages={'required': 'Enter your telephone number'}) def clean(self): data = self.cleaned_data description = data.get('organisation_description') categories = data.get('categories') if categories == 'Other' and not description: self.add_error('organisation_description', 'Enter your organisation') else: return data
class AnonymousSubscribeForm(forms.Form): error_css_class = 'input-field-container has-error' PLEASE_SELECT_LABEL = _('Please select an industry') TERMS_CONDITIONS_MESSAGE = _( 'Tick the box to confirm you agree to the terms and conditions.') full_name = fields.CharField(label=_('Your name')) email_address = fields.EmailField(label=_('Email address')) sector = fields.ChoiceField(label=_('Industry'), choices=([['', PLEASE_SELECT_LABEL]] + list(choices.INDUSTRIES))) company_name = fields.CharField(label=_('Company name')) country = fields.CharField(label=_('Country')) terms = fields.BooleanField( error_messages={'required': TERMS_CONDITIONS_MESSAGE})
class UserAccount(forms.Form): PASSWORD_HELP_TEXT = ('<p>Your password must:</p>' '<ul class="list list-bullet">' '<li>be at least 10 characters</li>' '<li>contain at least 1 letter</li>' '<li>contain at least 1 number</li>' '<li>not contain the word "password"</li>' '</ul>') MESSAGE_NOT_MATCH = "Passwords don't match" MESSAGE_PASSWORD_INVALID = 'Invalid Password' email = fields.EmailField(label='Your email address') password = fields.CharField(help_text=mark_safe(PASSWORD_HELP_TEXT), widget=PasswordInput) password_confirmed = fields.CharField( label='Confirm password', widget=PasswordInput, ) captcha = ReCaptchaField( label='', label_suffix='', ) terms_agreed = fields.BooleanField(label=mark_safe( 'Tick this box to accept the ' f'<a href="{urls.TERMS_AND_CONDITIONS}" target="_blank">terms and ' 'conditions</a> of the great.gov.uk service.')) def clean_password_confirmed(self): value = self.cleaned_data['password_confirmed'] if value != self.cleaned_data['password']: raise ValidationError(self.MESSAGE_NOT_MATCH) return value def clean(self): cleaned_data = super().clean() try: cleaned_data['user_details'] = helpers.create_user( email=cleaned_data['email'], password=cleaned_data['password'], ) except HTTPError as error: if error.response.status_code == 400: self.add_error('password', self.MESSAGE_PASSWORD_INVALID) else: raise return None
class TextBoxForm(PrefixIdMixin, forms.Form): text_field1 = fields.CharField(label='Q1: Simple text field', help_text='Some help text') url_field = fields.URLField(label='Q2: URL field', help_text='Some help text') email_field = fields.EmailField( label='Q3: Email field', help_text='Some email field help text', ) choice_field = fields.ChoiceField(label='Q4: select field', help_text='Some help text', choices=[ ('red', 'Red'), ('green', 'Green'), ('blue', 'Blue'), ])
class FeedbackForm(SerializeDataMixin, ZendeskActionMixin, forms.Form): name = fields.CharField(validators=anti_phising_validators) email = fields.EmailField() comment = fields.CharField(label='Feedback', widget=Textarea, validators=anti_phising_validators) captcha = ReCaptchaField( label='', label_suffix='', ) terms_agreed = fields.BooleanField(label=TERMS_LABEL) @property def full_name(self): assert self.is_valid() return self.cleaned_data['name']
class DomesticContactForm(FieldsMutationMixin, SerializeMixin, ZendeskActionMixin, forms.Form): first_name = fields.CharField() last_name = fields.CharField() email = fields.EmailField() organisation_type = fields.ChoiceField(label_suffix='', widget=widgets.RadioSelect(), choices=COMPANY_CHOICES) company_name = fields.CharField() comment = fields.CharField(widget=Textarea, validators=[no_html, not_contains_url_or_email]) captcha = ReCaptchaField( label='', label_suffix='', ) terms_agreed = fields.BooleanField(label=TERMS_LABEL)
class InternationalContactForm(FieldsMutationMixin, SerializeMixin, ZendeskActionMixin, forms.Form): first_name = fields.CharField() last_name = fields.CharField() email = fields.EmailField() organisation_type = fields.ChoiceField( label_suffix='', widget=widgets.RadioSelect(), choices=COMPANY_CHOICES, ) company_name = fields.CharField() country = fields.ChoiceField( choices=[('', 'Please select')] + choices.COUNTRY_CHOICES, widget=Select(attrs={'id': 'js-country-select'}), ) city = fields.CharField() comment = fields.CharField(widget=Textarea, validators=[no_html, not_contains_url_or_email]) captcha = ReCaptchaField( label='', label_suffix='', ) terms_agreed = fields.BooleanField(label=TERMS_LABEL)
class ResendVerificationCode(forms.Form): email = fields.EmailField(label='Your email address')
class ContactForm(forms.Form): action_class = EmailAction name = fields.CharField(label=_('Name')) job_title = fields.CharField(label=_('Job title')) email = fields.EmailField(label=_('Email address')) phone_number = fields.CharField(label=_('Phone number'), required=True) company_name = fields.CharField(label=_('Company name')) company_website = fields.CharField(label=_('Company website'), required=False) country = fields.ChoiceField( label=_('Which country are you based in?'), help_text=_('We will use this information to put you in touch with ' 'your closest British embassy or high commission.'), choices=[('', '')] + COUNTRIES, widget=Select(attrs={'id': 'js-country-select'})) staff_number = fields.ChoiceField(label=_('Current number of staff'), choices=STAFF_CHOICES) description = fields.CharField( label=_('Tell us about your investment'), help_text=_('Tell us about your company and your plans for the UK in ' 'terms of size of investment, operational and recruitment ' 'plans. Please also tell us what help you would like from ' 'the UK government.'), widget=Textarea()) captcha = ReCaptchaField( label='', label_suffix='', ) def __init__(self, utm_data, submission_url, *args, **kwargs): self.utm_data = utm_data self.submission_url = submission_url super().__init__(*args, **kwargs) def get_context_data(self): data = self.cleaned_data.copy() return { 'form_data': ((_('Name'), data['name']), (_('Email address'), data['email']), (_('Job title'), data['job_title']), (_('Phone number'), data['phone_number']), (_('Company name'), data['company_name']), (_('Company website'), data.get('company_website', '')), (_('Country'), data['country']), (_('Current number of staff'), data['staff_number']), (_('Your investment'), data['description'])), 'utm': self.utm_data, 'submission_url': self.submission_url, } def render_email(self, template_name): context = self.get_context_data() return render_to_string(template_name, context) 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_user_email(self): # no need to set `sender` as this is just a confirmation email. action = self.action_class( recipients=[self.cleaned_data['email']], subject=str(_('Contact form user email subject')), reply_to=[settings.DEFAULT_FROM_EMAIL], form_url=self.submission_url, ) response = action.save({ 'text_body': self.render_email('email/email_user.txt'), 'html_body': self.render_email('email/email_user.html'), }) response.raise_for_status() def save(self): self.send_agent_email() self.send_user_email()
class EmailAddressForm(forms.Form): email_address = fields.EmailField(label='Email address')
class CommunityJoinForm(GovNotifyActionMixin, Form): name = fields.CharField( label=_('Full name'), min_length=2, max_length=50, error_messages={'required': _('Enter your full name')}) email = fields.EmailField( label=_('Email address'), error_messages={ 'required': _('Enter an email address in the correct format,' ' like [email protected]'), 'invalid': _('Enter an email address in the correct format,' ' like [email protected]'), }) phone_number_regex = re.compile(r'^(\+\d{1,3}[- ]?)?\d{8,16}$') phone_number = fields.CharField( label=_('UK telephone number'), min_length=8, help_text=_('This can be a landline or mobile number'), error_messages={ 'max_length': _('Figures only, maximum 16 characters,' ' minimum 8 characters excluding spaces'), 'min_length': _('Figures only, maximum 16 characters,' ' minimum 8 characters excluding spaces'), 'required': _('Enter an UK phone number'), 'invalid': _('Please enter an UK phone number') }) company_name = fields.CharField(label=_('Business name'), max_length=50, error_messages={ 'required': _('Enter your business name'), }) company_location = fields.CharField(label=_('Business location'), max_length=50, error_messages={ 'required': _('Enter your business location'), }) sector = fields.ChoiceField(label=_('Sector'), choices=choices.COMPANY_SECTOR_CHOISES, error_messages={ 'required': _('Choose a sector'), }) sector_other = fields.CharField( label=_('Please specify'), widget=TextInput(attrs={'class': 'js-field-other'}), required=False, ) company_website = fields.CharField( label=_('Website'), max_length=255, help_text=_('Enter the home page address'), error_messages={ 'required': _('Enter a website address in the correct format, ' 'like https://www.example.com or www.company.com'), 'invalid': _('Enter a website address in the correct format, ' 'like https://www.example.com or www.company.com') }, required=False) employees_number = fields.ChoiceField( label=_('Number of employees'), choices=choices.EMPLOYEES_NUMBER_CHOISES, error_messages={ 'required': _('Choose a number'), }) currently_export = fields.ChoiceField( label=_('Do you currently export?'), choices=(('yes', 'Yes'), ('no', 'No')), widget=widgets.RadioSelect, error_messages={'required': _('Please answer this question')}) advertising_feedback = fields.ChoiceField( label=_('Where did you hear about becoming an Export Advocate?'), choices=choices.HEARD_ABOUT_CHOISES, error_messages={ 'required': _('Please tell us where you heard about' ' becoming an Export Advocate'), }) advertising_feedback_other = fields.CharField( label=_('Please specify'), widget=TextInput(attrs={'class': 'js-field-other'}), required=False, ) terms_agreed = fields.BooleanField( label=TERMS_LABEL, error_messages={ 'required': _('You must agree to the terms and conditions' ' before registering'), }) captcha = ReCaptchaField( label='', label_suffix='', error_messages={ 'required': _('Check the box to confirm that you’re human') }) def clean_phone_number(self): phone_number = self.cleaned_data.get('phone_number', '').replace(' ', '') if not self.phone_number_regex.match(phone_number): raise forms.ValidationError(_('Please enter an UK phone number')) return phone_number @property def serialized_data(self): data = super().serialized_data sector_mapping = dict(choices.COMPANY_SECTOR_CHOISES) employees_number_mapping = dict(choices.EMPLOYEES_NUMBER_CHOISES) advertising_feedback_mapping = dict(choices.HEARD_ABOUT_CHOISES) if data.get('sector_other'): sector_label = data.get('sector_other') else: sector_label = sector_mapping.get(data['sector']) data['sector_label'] = sector_label if data.get('advertising_feedback_other'): advertising_feedback_label = data.get('advertising_feedback_other') else: advertising_feedback_label = advertising_feedback_mapping.get( data['advertising_feedback']) data['advertising_feedback_label'] = advertising_feedback_label data['employees_number_label'] = employees_number_mapping.get( data['employees_number']) return data
class ContactForm(GovNotifyActionMixin, forms.Form): def __init__(self, industry_choices, *args, **kwargs): super().__init__(*args, **kwargs) self.fields['terms_agreed'].widget.label = mark_safe( ugettext('I agree to the <a href="{url}" target="_blank">' 'great.gov.uk terms and conditions</a>').format( url=urls.TERMS_AND_CONDITIONS)) self.fields['sector'].choices = industry_choices full_name = fields.CharField( label=_('Full name'), max_length=255, validators=[not_contains_url_or_email], widget=TextInput(attrs={'dir': 'auto'}), ) email_address = fields.EmailField( label=_('Email address'), widget=TextInput(attrs={'dir': 'auto'}), ) phone_number = fields.CharField( label=_('Phone number'), widget=TextInput(attrs={'dir': 'auto'}), ) sector = fields.ChoiceField( label=_('Your industry'), choices=[], # set in __init__ ) organisation_name = fields.CharField( label=_('Your organisation name'), max_length=255, validators=[not_contains_url_or_email], widget=TextInput(attrs={'dir': 'auto'}), ) organisation_size = fields.ChoiceField( label=_('Size of your organisation'), choices=choices.EMPLOYEES, required=False, ) country = fields.CharField( label=_('Your country'), max_length=255, validators=[not_contains_url_or_email], widget=TextInput(attrs={'dir': 'auto'}), ) body = fields.CharField( label=_('Describe what products or services you need'), help_text=_('Maximum 1000 characters.'), max_length=1000, widget=Textarea(attrs={'dir': 'auto'}), validators=[not_contains_url_or_email], ) source = fields.ChoiceField( label=_('Where did you hear about great.gov.uk?'), choices=(('', ''), ) + constants.MARKETING_SOURCES, required=False, initial=' ', # prevent "other" being selected by default widget=Select(attrs={'class': 'js-field-other-selector'})) source_other = fields.CharField( label=_("Other source (optional)"), required=False, widget=TextInput(attrs={ 'class': 'js-field-other', 'dir': 'auto', }), validators=[not_contains_url_or_email], ) terms_agreed = fields.BooleanField() captcha = ReCaptchaField() @property def serialized_data(self): # this data will be sent to zendesk. `captcha` and `terms_agreed` are # not useful to the zendesk user as those fields have to be present # for the form to be submitted. data = self.cleaned_data.copy() del data['captcha'] del data['terms_agreed'] return data
class ContactCompanyForm(GovNotifyActionMixin, forms.Form): TERMS_CONDITIONS_LABEL = ( '<p>I agree to the great.gov.uk terms and conditions and I ' 'understand that:</p>' '<ul class="list list-bullet">' '<li>the Department for International Trade (DIT) has reasonably ' 'tried to ensure that businesses listed in the UK Investment Support ' 'Directory are appropriately qualified and that the information in ' 'this directory is accurate and up to date</li>' '<li>DIT is not endorsing the character, ability, goods or services ' 'of members of the directory</li>' '<li>there is no legal relationship between DIT and directory ' 'members</li>' '<li>DIT is not liable for any direct or indirect loss or damage that ' 'might happen after a directory member provides a good or service</li>' '<li>directory members will give 1 hour’s free consultation to ' 'businesses that contact them through this service</li>' '</ul>') TERMS_CONDITIONS_MESSAGE = ( 'Tick the box to confirm you agree to the terms and conditions.') given_name = fields.CharField( label='Given name', max_length=255, validators=[not_contains_url_or_email], ) family_name = fields.CharField( label='Family name', max_length=255, validators=[not_contains_url_or_email], ) company_name = fields.CharField( label='Your organisation name', max_length=255, validators=[not_contains_url_or_email], ) email_address = fields.EmailField(label='Email address', ) sector = fields.ChoiceField( label='Industry', choices=([['', 'Please select your industry']] + list(choices.INDUSTRIES)), ) subject = fields.CharField( label='Enter a subject line for your message', max_length=200, validators=[not_contains_url_or_email], ) body = fields.CharField( label='Enter your message to the UK company', help_text='Maximum 1000 characters.', max_length=1000, widget=Textarea, validators=[not_contains_url_or_email], ) has_contact = fields.ChoiceField(label=( 'Do you currently have a contact at Department of international ' 'trade'), widget=widgets.RadioSelect( use_nice_ids=True, attrs={'id': 'radio-one'}), choices=( (True, 'Yes'), (False, 'No'), )) terms = fields.BooleanField( label=mark_safe(TERMS_CONDITIONS_LABEL), error_messages={'required': TERMS_CONDITIONS_MESSAGE}, ) captcha = ReCaptchaField(label='')
class HighPotentialOpportunityForm(forms.Form): action_class = GovNotifyAction COMPANY_SIZE_CHOICES = [ ('1 - 10', '1 - 10'), ('11 - 50', '11 - 50'), ('51 - 250', '51 - 250'), ('250+', '250+'), ] def __init__(self, field_attributes, opportunity_choices, *args, **kwargs): for field_name, field in self.base_fields.items(): attributes = field_attributes.get(field_name) if attributes: field.__dict__.update(attributes) self.base_fields['opportunities'].choices = opportunity_choices return super().__init__(*args, **kwargs) full_name = fields.CharField() role_in_company = fields.CharField() email_address = fields.EmailField() phone_number = fields.CharField() company_name = fields.CharField() website_url = fields.CharField(required=False) country = fields.ChoiceField( choices=[('', 'Please select')] + choices.COUNTRY_CHOICES, widget=Select(attrs={'id': 'js-country-select'}), ) company_size = fields.ChoiceField(choices=COMPANY_SIZE_CHOICES) opportunities = fields.MultipleChoiceField( widget=widgets.CheckboxSelectInlineLabelMultiple( attrs={'id': 'checkbox-multiple'}, use_nice_ids=True, ), choices=[] # set in __init__ ) comment = fields.CharField(widget=Textarea, required=False) terms_agreed = fields.BooleanField(label=mark_safe( 'Tick this box to accept the ' f'<a href="{urls.TERMS_AND_CONDITIONS}" target="_blank">terms and ' 'conditions</a> of the great.gov.uk service.')) captcha = ReCaptchaField( label='', label_suffix='', ) @property def serialized_data(self): formatted_opportunities = [ '• {opportunity[1]}: {opportunity[0]}'.format(opportunity=item) for item in self.base_fields['opportunities'].choices if item[0] in self.cleaned_data['opportunities'] ] return { **self.cleaned_data, 'opportunity_urls': '\n'.join(formatted_opportunities), } 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() def send_user_email(self, form_url): # no need to set `sender` as this is just a confirmation email. action = self.action_class( template_id=settings.HPO_GOV_NOTIFY_USER_TEMPLATE_ID, email_address=self.cleaned_data['email_address'], form_url=form_url, email_reply_to_id=settings.HPO_GOV_NOTIFY_USER_REPLY_TO_ID, ) response = action.save(self.serialized_data) response.raise_for_status() def save(self, form_url): self.send_agent_email(form_url=form_url) self.send_user_email(form_url=form_url)