Exemplo n.º 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())
Exemplo n.º 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')
Exemplo n.º 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)
Exemplo n.º 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',
    )
Exemplo n.º 5
0
class RadioNestedForm(forms.BindNestedFormMixin, forms.Form):
    OTHER = 'OTHER'
    parent_field = forms.RadioNested(
        choices=[
            ('KG', 'Kilograms'),
            ('HANDS', 'Hands'),
            (OTHER, 'other')
        ],
        nested_form_class=PaddedTestForm,
        nested_form_choice=OTHER,
    )
    other_field = forms.CharField()
Exemplo n.º 6
0
class HelpForm(ConsentFieldMixin, forms.Form):
    error_css_class = 'input-field-container has-error'

    comment = forms.CharField(
        label=
        'Tell us about your export experience, including any challenges you are facing.',
        help_text=("We're particularly interested in the markets you "
                   'have exported to and whether you have already '
                   'spoken to your bank or a broker. '),
        widget=Textarea(attrs={'class': 'margin-top-15'}),
    )
    captcha = ReCaptchaField(label='', label_suffix='', widget=ReCaptchaV3())
Exemplo n.º 7
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)
Exemplo n.º 8
0
class CompanyDetailsForm(forms.Form):

    EXPORT_CHOICES = (
        'I have three years of registered accounts',
        'I have customers outside UK',
        'I supply companies that sell overseas',
    )
    INDUSTRY_CHOICES = (
        [('', '')] + [(value.replace('_', ' ').title(), label)
                      for (value, label) in choices.INDUSTRIES]  # noqa: W503
        + [('Other', 'Other')]  # noqa: W503
    )

    error_css_class = 'input-field-container has-error'

    trading_name = forms.CharField(label='Registered name')
    company_number = forms.CharField(label='Companies House number',
                                     required=False)
    address_line_one = forms.CharField(label='Building and street')
    address_line_two = forms.CharField(label='', required=False)
    address_town_city = forms.CharField(label='Town or city')
    address_county = forms.CharField(label='County')
    address_post_code = forms.CharField(label='Postcode')
    industry = forms.ChoiceField(initial='thing', choices=INDUSTRY_CHOICES)
    industry_other = forms.CharField(
        label='Type in your industry',
        widget=TextInput(attrs={'class': 'js-field-other'}),
        required=False,
    )

    export_status = forms.MultipleChoiceField(
        label='',
        widget=forms.CheckboxSelectInlineLabelMultiple(
            attrs={'id': 'checkbox-multiple'},
            use_nice_ids=True,
        ),
        choices=((choice, choice) for choice in EXPORT_CHOICES),
    )

    def clean(self):
        cleaned_data = super().clean()
        return {
            **cleaned_data, 'not_companies_house':
            not cleaned_data.get('company_number')
        }
Exemplo n.º 9
0
class DemoFormErrors(PrefixIdMixin, forms.Form):
    error_summary_heading = 'There was a problem submitting the form'

    text_field1 = forms.CharField(label='Simple text field',
                                  help_text='Some help text',
                                  required=True)
    checkbox1 = forms.BooleanField(
        label='Label text',
        required=True,
        help_text=('Some help text.'),
        widget=forms.CheckboxWithInlineLabel(attrs={'id': 'checkbox-one'}))
    multiple_choice = forms.MultipleChoiceField(
        label='Multiple choice checkboxes',
        required=True,
        help_text='Some help text.',
        widget=forms.CheckboxSelectInlineLabelMultiple(
            attrs={'id': 'checkbox-multiple'},
            use_nice_ids=True,
        ),
        choices=(
            ('red', 'Red'),
            ('green', 'Green'),
            ('blue', 'Blue'),
        ),
    )

    radio = forms.ChoiceField(
        label='Radio select',
        required=True,
        label_suffix='',
        help_text='Some help text.',
        widget=forms.RadioSelect(use_nice_ids=True, attrs={'id': 'radio-one'}),
        choices=(
            (True, 'Yes'),
            (False, 'No'),
        ))

    def clean(self, *args, **kwargs):
        self.add_error(
            field=None,
            error=['Some non-field error', 'Some other non-field error'])
        super().clean(*args, **kwargs)
Exemplo n.º 10
0
class ProductSearchForm(forms.Form):
    products = forms.CharField()
Exemplo n.º 11
0
class DemoNestedFormDetails(forms.Form):
    metric_name = forms.CharField()
    more_details = forms.CharField(
        label='more details',
        widget=Textarea(attrs={'rows': 3}),
    )
Exemplo n.º 12
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
Exemplo n.º 13
0
class MarketAccessProblemDetailsForm(forms.Form):

    error_css_class = 'input-field-container has-error'

    location = forms.ChoiceField(
        choices=LOCATION_CHOICES,
        label='Where are you trying to export to or invest in?',
        error_messages={
            'required':
            'Tell us where you are trying to export to or invest in',
        },
    )
    product_service = forms.CharField(
        label='What goods or services do you want to export?',
        help_text='Or tell us about an investment you want to make',
        error_messages={
            'required': 'Tell us what you’re trying to export or invest in',
        },
    )
    problem_summary = forms.CharField(
        label=mark_safe((
            '<p>Tell us about your problem, including: </p>'
            '<ul class="list list-bullet">'
            '<li>what’s affecting your export or investment</li>'
            '<li>when you became aware of the problem</li>'
            '<li>how you became aware of the problem</li>'
            '<li>if this has happened before</li>'
            '<li>'
            'any information you’ve been given or '
            'correspondence you’ve had'
            '</li>'
            '<li>'
            'the HS (Harmonized System) code for your goods, '
            'if you know it'
            '</li>'
            '<li>'
            'if it is an existing barrier include the trade '
            'barrier code and title (to find the title and '
            'code visit '
            '<a href="https://www.gov.uk/barriers-trading-investing-abroad" target="_blank" class="link">'
            'check for barriers to trading and investing abroad</a>.)'
            '</li>'
            '</ul>')),
        widget=Textarea,
        error_messages={'required': 'Tell us about the problem you’re facing'},
    )
    impact = forms.CharField(
        label=
        'How has the problem affected your business or industry, or how could it affect it?',
        widget=Textarea,
        error_messages={
            'required':
            'Tell us how your business or industry is being affected by the problem',
        },
    )
    resolve_summary = forms.CharField(
        label=mark_safe(('<p>Tell us about any steps you’ve taken '
                         'to resolve the problem, including: </p>'
                         '<ul class="list list-bullet">'
                         '<li>people you’ve contacted</li>'
                         '<li>when you contacted them</li>'
                         '<li>what happened</li>'
                         '</ul>')),
        widget=Textarea,
        error_messages={
            'required':
            'Tell us what you’ve done to resolve your problem, even if this is your first step'
        },
    )
    problem_cause = forms.MultipleChoiceField(
        label='Is the problem caused by or related to any of the following?',
        widget=MarketAccessTickboxWithOptionsHelpText(
            use_nice_ids=True,
            attrs={
                'id': 'radio-one',
                'help_text': {
                    'radio-one-covid-19':
                    'Problem related to the COVID-19 (coronavirus) pandemic.',
                },
            },
        ),
        choices=PROBLEM_CAUSE_CHOICES,
        required=False,
    )

    def clean_location(self):
        value = self.cleaned_data['location']
        self.cleaned_data['location_label'] = LOCATION_MAP[value]
        return value

    def clean_problem_cause(self):
        value = self.cleaned_data['problem_cause']
        self.cleaned_data['problem_cause_label'] = [
            PROBLEM_CAUSE_MAP[item] for item in value
        ]
        return value
Exemplo n.º 14
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
Exemplo n.º 15
0
class DemoFormWithSubmitButton(forms.Form):
    term = forms.CharField(
        label='',
        widget=forms.TextInputWithSubmitButton,
    )
Exemplo n.º 16
0
class CompanyNameForm(forms.Form):
    name = forms.CharField()
Exemplo n.º 17
0
 class Form(forms.Form):
     field = forms.CharField()
Exemplo n.º 18
0
 class Form(forms.Form):
     field_one = forms.CharField()
     field_two = forms.CharField(widget=HiddenInput())
Exemplo n.º 19
0
class CompaniesHouseSearchForm(forms.Form):
    term = forms.CharField()
Exemplo n.º 20
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