示例#1
0
class EUExitDomesticContactForm(
        SerializeMixin,
        ZendeskActionMixin,
        ConsentFieldMixin,
        forms.Form,
):

    COMPANY = 'COMPANY'

    COMPANY_CHOICES = (
        (COMPANY, 'Company'),
        ('OTHER', 'Other type of organisation'),
    )

    first_name = forms.CharField()
    last_name = forms.CharField()
    email = forms.EmailField()
    organisation_type = forms.ChoiceField(
        label='Business type',
        widget=forms.RadioSelect(),
        choices=COMPANY_CHOICES,
    )
    company_name = forms.CharField()
    comment = forms.CharField(
        label='Your question',
        help_text="Please don't share any commercially sensitive information.",
        widget=Textarea,
        validators=[
            no_html,
            not_contains_url_or_email,
        ],
    )
    captcha = ReCaptchaField(label='', label_suffix='', widget=ReCaptchaV3())
示例#2
0
class PersonalDetailsForm(forms.Form):
    error_css_class = 'input-field-container has-error'

    firstname = forms.CharField(label='Your first name')
    lastname = forms.CharField(label='Your last name')
    position = forms.CharField(label='Position in company')
    email = forms.EmailField(label='Email address')
    phone = forms.CharField(label='Phone')
示例#3
0
class ContactUsHelpForm(GovNotifyEmailActionMixin, forms.Form):
    comment = forms.CharField(
        label='Please give us as much detail as you can',
        widget=Textarea,
    )
    given_name = forms.CharField(label='First name')
    family_name = forms.CharField(label='Last name')
    email = forms.EmailField()
    captcha = ReCaptchaField(label='', label_suffix='', widget=ReCaptchaV3())
    terms_agreed = forms.BooleanField(label=TERMS_LABEL)
示例#4
0
class TextBoxForm(PrefixIdMixin, forms.Form):
    text_field1 = forms.CharField(label='Q1: Simple text field')
    url_field = forms.URLField(label='Q2: URL field')
    email_field = forms.EmailField(
        label='Q3: Email field',
        help_text='Some email field help text',
    )
    choice_field = forms.ChoiceField(label='Q4: select field',
                                     help_text='Some help text',
                                     choices=[
                                         ('red', 'Red'),
                                         ('green', 'Green'),
                                         ('blue', 'Blue'),
                                     ])
    text_field2 = forms.CharField(
        label='Q5: Custom css class on container',
        help_text='Some help text',
        container_css_classes='form-group bg-stone-30 p-m',
    )
示例#5
0
class BaseShortForm(forms.Form):
    comment = forms.CharField(
        label='Please give us as much detail as you can',
        widget=Textarea,
    )
    given_name = forms.CharField(label='First name')
    family_name = forms.CharField(label='Last name')
    email = forms.EmailField()
    company_type = forms.ChoiceField(
        label='Company type',
        label_suffix='',
        widget=forms.RadioSelect(),
        choices=COMPANY_TYPE_CHOICES,
    )
    company_type_other = forms.ChoiceField(
        label='Type of organisation',
        label_suffix='',
        choices=(('', 'Please select'), ) + COMPANY_TYPE_OTHER_CHOICES,
        required=False,
    )
    organisation_name = forms.CharField()
    postcode = forms.CharField()
    captcha = ReCaptchaField(label='', label_suffix='', widget=ReCaptchaV3())
    terms_agreed = forms.BooleanField(label=TERMS_LABEL)
示例#6
0
class ExportSupportForm(GovNotifyEmailActionMixin, forms.Form):

    EMPLOYEES_NUMBER_CHOICES = (
        ('1-9', '1 to 9'),
        ('10-49', '10 to 49'),
        ('50-249', '50 to 249'),
        ('250-499', '250 to 499'),
        ('500plus', 'More than 500'),
    )

    first_name = forms.CharField(
        label='First name',
        min_length=2,
        max_length=50,
        error_messages={'required': 'Enter your first name'})
    last_name = forms.CharField(
        label='Last name',
        min_length=2,
        max_length=50,
        error_messages={'required': 'Enter your last name'})
    email = forms.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 = forms.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 a UK phone number',
            'invalid': 'Please enter a UK phone number',
        },
    )
    job_title = forms.CharField(
        label='Job title',
        max_length=50,
        error_messages={
            'required': 'Enter your job title',
        },
    )
    company_name = forms.CharField(
        label='Business name',
        max_length=50,
        error_messages={
            'required': 'Enter your business name',
        },
    )
    company_postcode = forms.CharField(
        label='Business postcode',
        max_length=50,
        error_messages={
            'required': 'Enter your business postcode',
            'invalid': 'Please enter a UK postcode'
        },
        validators=[is_valid_uk_postcode],
    )
    annual_turnover = forms.ChoiceField(
        label='Annual turnover',
        help_text=
        ('This information will help us tailor our response and advice on the services we can provide.'
         ),
        choices=(
            ('Less than £500K', 'Less than £500K'),
            ('£500K to £2M', '£500K to £2M'),
            ('£2M to £5M', '£2M to £5M'),
            ('£5M to £10M', '£5M to £10M'),
            ('£10M to £50M', '£10M to £50M'),
            ('£50M or higher', '£50M or higher'),
        ),
        widget=forms.RadioSelect,
        required=False,
    )
    employees_number = forms.ChoiceField(
        label='Number of employees',
        choices=EMPLOYEES_NUMBER_CHOICES,
        widget=forms.RadioSelect,
        error_messages={
            'required': 'Choose a number',
        },
    )
    currently_export = forms.ChoiceField(
        label='Do you currently export?',
        choices=(('yes', 'Yes'), ('no', 'No')),
        widget=forms.RadioSelect,
        error_messages={'required': 'Please answer this question'},
    )

    terms_agreed = forms.BooleanField(
        label=TERMS_LABEL,
        error_messages={
            'required':
            'You must agree to the terms and conditions before registering',
        },
    )
    comment = forms.CharField(
        label='Please give us as much detail as you can on your enquiry',
        widget=Textarea,
    )
    captcha = ReCaptchaField(label='', label_suffix='', widget=ReCaptchaV3())

    def clean_phone_number(self):
        phone_number = self.cleaned_data['phone_number'].replace(' ', '')
        if not PHONE_NUMBER_REGEX.match(phone_number):
            raise ValidationError('Please enter a UK phone number')
        return phone_number

    def clean_company_postcode(self):
        return self.cleaned_data['company_postcode'].replace(' ', '').upper()

    @property
    def serialized_data(self):
        data = super().serialized_data
        employees_number_mapping = dict(self.EMPLOYEES_NUMBER_CHOICES)
        data['employees_number_label'] = employees_number_mapping.get(
            data['employees_number'])
        return data
示例#7
0
class MarketAccessAboutForm(forms.Form):
    error_css_class = 'input-field-container has-error'
    CATEGORY_CHOICES = (
        'I’m an exporter or investor, or I want to export or invest',
        'I work for a trade association',
        'Other',
    )

    firstname = forms.CharField(
        label='First name',
        error_messages={'required': 'Enter your first name'},
    )

    lastname = forms.CharField(
        label='Last name',
        error_messages={'required': 'Enter your last name'},
    )

    jobtitle = forms.CharField(
        label='Job title',
        error_messages={'required': 'Enter your job title'},
    )

    business_type = forms.ChoiceField(
        label='Business type',
        widget=forms.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'},
    )
    other_business_type = forms.CharField(
        label='Tell us about your organisation',
        widget=TextInput(attrs={'class': 'js-field-other'}),
        required=False,
    )

    company_name = forms.CharField(
        label='Business or organisation name',
        error_messages={
            'required': 'Enter your business or organisation name'
        },
    )

    email = forms.EmailField(
        label='Email address',
        error_messages={'required': 'Enter your email address'},
    )

    phone = forms.CharField(
        label='Telephone number',
        error_messages={'required': 'Enter your telephone number'},
    )

    def clean(self):
        data = self.cleaned_data
        other_business_type = data.get('other_business_type')
        business_type = data.get('business_type')
        if business_type == 'Other' and not other_business_type:
            self.add_error('other_business_type', 'Enter your organisation')
        else:
            return data
示例#8
0
class UKEFContactForm(GovNotifyEmailActionMixin, forms.Form):
    full_name = forms.CharField(
        label=_('Full name'),
        min_length=2,
        max_length=50,
        error_messages={
            'required': _('Enter your full name'),
        },
    )
    job_title = forms.CharField(
        label=_('Job title'),
        max_length=50,
        error_messages={
            'required': _('Enter your job title'),
        },
    )
    email = forms.EmailField(
        label=_('Business 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]'
              ),
        },
    )
    business_name = forms.CharField(
        label=_('Business name'),
        max_length=50,
        error_messages={
            'required': _('Enter your business name'),
        },
    )
    business_website = forms.CharField(
        label=_('Business website'),
        max_length=255,
        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,
    )
    country = forms.ChoiceField(
        label=_('Which country are you based in?'),
        widget=Select(),
        choices=COUNTRIES,
    )
    like_to_discuss = forms.ChoiceField(
        label=_(
            'Do you have a specific project or proposal you’d like to discuss?'
        ),
        choices=(
            ('no', 'No'),
            ('yes', 'Yes'),
        ),
        widget=forms.RadioSelect,
        error_messages={'required': _('Please answer this question')},
    )
    like_to_discuss_other = forms.ChoiceField(
        label=_('Which country is the project located in?'),
        widget=Select(),
        choices=COUNTRIES,
        required=False,
    )
    how_can_we_help = forms.CharField(
        label=_('How can we help?'),
        help_text=_(
            'Please tell us briefly what type of support you’re looking for'),
        widget=Textarea,
    )
    terms_agreed = forms.BooleanField(
        label=TERMS_LABEL,
        error_messages={
            'required':
            _('You must agree to the terms and conditions'
              ' before registering'),
        },
    )
    captcha = ReCaptchaField(
        label='',
        label_suffix='',
        widget=ReCaptchaV3(),
    )

    @property
    def serialized_data(self):
        data = super().serialized_data
        countries_mapping = dict(COUNTRY_CHOICES)
        country_label = countries_mapping.get(data['country'])
        data['country_label'] = country_label
        data['like_to_discuss_country'] = ''
        if data.get('like_to_discuss') == 'yes':
            data['like_to_discuss_country'] = countries_mapping.get(
                data['like_to_discuss_other'])
        return data