class CompanyPublicContactInformationForm(FlaskForm): company_name = DMStripWhitespaceStringField( 'Company name', validators=[ InputRequired(message="Enter your company name."), Length(max=255, message="Enter a company name under 256 characters.") ]) contact_name = DMStripWhitespaceStringField( 'Contact name', validators=[ InputRequired(message="Enter a contact name."), Length(max=255, message="Enter a contact name under 256 characters.") ]) email_address = DMStripWhitespaceStringField( 'Contact email address', validators=[ InputRequired(message="Enter an email address."), EmailValidator(message="Enter a valid email address."), ]) phone_number = DMStripWhitespaceStringField( 'Contact phone number', validators=[ InputRequired(message="Enter a phone number."), Length(max=20, message="Enter a phone number under 20 characters.") ])
class SignerDetailsForm(FlaskForm): signerName = DMStripWhitespaceStringField( "Full name", validators=[ DataRequired( message= "You must provide the full name of the person signing on behalf of the company." ), Length(max=255, message="You must provide a name under 256 characters."), ], ) signerRole = DMStripWhitespaceStringField( "Role at the company", hint= "The person signing must have the authority to agree to the framework terms," " eg director or company secretary.", validators=[ DataRequired( message= "You must provide the role of the person signing on behalf of the company." ), Length(max=255, message="You must provide a role under 256 characters."), ], )
class CompanyPublicContactInformationForm(FlaskForm): company_name = DMStripWhitespaceStringField( 'Company name', validators=[ InputRequired(message="Enter your company name"), Length(max=255, message="Company name must be %(max)d characters or fewer") ]) contact_name = DMStripWhitespaceStringField( 'Contact name', validators=[ InputRequired(message="Enter a contact name"), Length(max=255, message="Contact name must be %(max)d characters or fewer") ]) email_address = DMStripWhitespaceStringField( 'Contact email address', validators=[ InputRequired(message="Enter an email address"), EmailValidator( message= "Enter an email address in the correct format, like [email protected]" ), ]) phone_number = DMStripWhitespaceStringField( 'Contact phone number', validators=[ InputRequired(message="Enter a phone number"), Length(max=20, message="Phone number must be %(max)d characters or fewer") ])
class SignFrameworkAgreementForm(FlaskForm): def __init__(self, contract_title, **kw): super(SignFrameworkAgreementForm, self).__init__(**kw) self.signer_terms_and_conditions.label.text = f"I accept the terms and conditions of the {contract_title}" self.signer_terms_and_conditions.validators[0].message = f"Accept the terms and conditions of the" \ f" {contract_title}." # Intended use of camel case here to match expected API fields signerName = DMStripWhitespaceStringField( "Your full name", validators=[ DataRequired(message="Enter your full name."), Length(max=255, message="Name must be under 256 characters."), ], ) signerRole = DMStripWhitespaceStringField( "Your role in the company", validators=[ DataRequired(message="Enter your role in the company."), Length(max=255, message="Role must be under 256 characters."), ], ) signer_terms_and_conditions = DMBooleanField( validators=[ DataRequired() ] )
class EditSupplierInformationForm(FlaskForm): contactName = DMStripWhitespaceStringField( "Contact name", hint= "This can be the name of the person or team you want buyers to contact", validators=[ InputRequired(message="Enter a contact name"), Length(max=255, message="Contact name must be %(max)d characters or fewer"), ]) email = DMEmailField( "Contact email address", hint="This is the email buyers will use to contact you", validators=[ InputRequired(message="Enter an email address"), EmailValidator( message= "Enter an email address in the correct format, like [email protected]" ), ]) phoneNumber = DMStripWhitespaceStringField( "Contact phone number", validators=[ InputRequired(message="Enter a phone number"), Length(max=20, message="Phone number must be %(max)d characters or fewer") ]) description = DMStripWhitespaceStringField( "Supplier summary", hint="50 words maximum", widget=DMTextArea(max_length_in_words=50), validators=[ word_length(50, "Your summary must not be more than %d words"), ])
class AddCompanyRegistrationNumberForm(FlaskForm): has_companies_house_number = RadioField( "Are you registered with Companies House?", id="input-has_companies_house_number-1", validators=[ InputRequired( message="Select yes if you are registered with Companies House" ) ], choices=[('Yes', 'Yes'), ('No', 'No')]) companies_house_number = DMStripWhitespaceStringField( 'Companies House number', id="input-has_companies_house_number-1-companies_house_number", default='', validators=[ Optional(), Regexp(r'^([0-9]{2}|[A-Za-z]{2})[0-9]{6}$', message="Your Companies House number must be 8 characters") ]) other_company_registration_number = DMStripWhitespaceStringField( 'Other company registration number', id= "input-has_companies_house_number-2-other_company_registration_number", default='', validators=[ Optional(), Length(max=255, message= "Registration number must be %(max)d characters or fewer") ]) def validate(self): # If the form has been re-submitted following an error on a field which is now hidden we need to clear the # previously entered data before validating # For example, a user had an error submitting CH number but is now submitting other registration number, # (with CH number field hidden on the page) the previously submitted bad CH number should be cleared. # Similarly, we clear any validation errors on fields that were "hidden" when the form was submitted. if self.has_companies_house_number.data == "Yes": self.other_company_registration_number.raw_data = None self.other_company_registration_number.data = "" if self.has_companies_house_number.data == "No": self.companies_house_number.raw_data = None self.companies_house_number.data = "" valid = True if not super(AddCompanyRegistrationNumberForm, self).validate(): valid = False if self.has_companies_house_number.data == "Yes" and not self.companies_house_number.data: self.companies_house_number.errors.append( 'Enter a Companies House number') valid = False if self.has_companies_house_number.data == "No" and not self.other_company_registration_number.data: self.other_company_registration_number.errors.append( 'Enter a company registration number') valid = False return valid
class EmailAddressForm(FlaskForm): email_address = DMStripWhitespaceStringField( 'Email address', validators=[ InputRequired(message="Enter an email address."), EmailValidator(message="Enter a valid email address."), ])
class DunsNumberForm(FlaskForm): duns_number = DMStripWhitespaceStringField( 'DUNS Number', validators=[ InputRequired(message="Enter your 9 digit DUNS number"), Regexp(r'^\d{9}$', message="Your DUNS number must be 9 digits"), ])
class CreateNewProjectForm(FlaskForm): project_name = DMStripWhitespaceStringField( "Name your search. A reference number or short description of what you want to buy makes a good name.", validators=[ Length(min=1, max=100, message="Enter a name for your search between 1 and 100 characters") ], )
class TellUsAboutContractForm(FlaskForm): INVALID_VALUE_MESSAGE = "Enter the value in pounds and pence, using numbers and decimals" start_date = DMDateField( "Start date", validators=[ DateValidator("the start date"), ], ) end_date = DMDateField( "End date", validators=[ DateValidator("the end date"), GreaterThan("start_date", "End date must be after the start date"), ], ) value_in_pounds = DMPoundsField( "Value", validators=[ InputRequired("Enter the contract value"), DataRequired(INVALID_VALUE_MESSAGE), NumberRange(min=Decimal('0.01'), message=INVALID_VALUE_MESSAGE), ], ) buying_organisation = DMStripWhitespaceStringField( "Organisation buying the service", hint="For example, National Audit Office or Lewisham Council", validators=[ InputRequired("Enter an organisation") ], )
class EmailAddressForm(FlaskForm): email_address = DMStripWhitespaceStringField( "Email address", hint="Enter the email address of the person you wish to invite", validators=[ validators.DataRequired(message="Email can not be empty"), validators.Email(message="Please enter a valid email address"), ])
class EditSupplierRegisteredAddressForm(FlaskForm): street = DMStripWhitespaceStringField( "Building and street", validators=[ InputRequired(message="You need to enter the street address."), Length( max=255, message= "You must provide a building and street name under 256 characters." ), ]) city = DMStripWhitespaceStringField( "Town or city", validators=[ InputRequired(message="You need to enter the town or city."), Length( max=255, message= "You must provide a town or city name under 256 characters."), ]) postcode = DMStripWhitespaceStringField( "Postcode", validators=[ InputRequired(message="You need to enter the postcode."), Length( max=15, message="You must provide a valid postcode under 15 characters." ), ]) country = DMStripWhitespaceStringField( "Country", validators=[ InputRequired(message="You need to enter a country."), AnyOf(values=[country[1] for country in COUNTRY_TUPLE], message="You must enter a valid country."), ]) def validate(self): # If a user is trying to change the country and enters an invalid option (blank or not a country), # and submits the form, the country field is not submitted with the form. # The old value will be re-populated in the field (with the validation error message). # This could be confusing if there are multiple fields with errors, so clear the field for now. if not self.country.raw_data: self.country.data = '' return super(EditSupplierRegisteredAddressForm, self).validate()
class EmailAddressForm(FlaskForm): email_address = DMStripWhitespaceStringField( 'Email address', id="input-email_address", hint=EMAIL_LOGIN_HINT, validators=[ DataRequired(message=EMAIL_EMPTY_ERROR_MESSAGE), Regexp(EMAIL_REGEX, message=EMAIL_INVALID_ERROR_MESSAGE) ])
class MoveUserForm(FlaskForm): user_to_move_email_address = DMStripWhitespaceStringField( "Move an existing user to this supplier", hint= "Enter the email address of the existing user you wish to move to this supplier", validators=[ validators.DataRequired(message="Email can not be empty"), validators.Email(message="Please enter a valid email address"), ])
class EmailAddressForm(FlaskForm): email_address = DMStripWhitespaceStringField( 'Email address', id="input_email_address", hint=EMAIL_LOGIN_HINT, validators=[ DataRequired(message="You must provide an email address"), Regexp(EMAIL_REGEX, message="You must provide a valid email address") ])
class AddCompanyRegisteredNameForm(FlaskForm): registered_company_name = DMStripWhitespaceStringField( 'Registered company name', validators=[ InputRequired(message="Enter your registered company name."), Length( max=255, message="Enter a registered company name under 256 characters." ) ])
class EmailAddressForm(FlaskForm): email_address = DMStripWhitespaceStringField( 'Email address', validators=[ InputRequired(message="Enter an email address"), EmailValidator( message= "Enter an email address in the correct format, like [email protected]" ), ])
class EmailAddressForm(FlaskForm): email_address = DMStripWhitespaceStringField( "Your email address", validators=[ DataRequired(message="Enter an email address"), ValidEmailAddress( message= "Enter an email address in the correct format, like [email protected]" ), ])
class AddCompanyRegisteredNameForm(FlaskForm): registered_company_name = DMStripWhitespaceStringField( 'Registered company name', validators=[ InputRequired(message="Enter your registered company name"), Length( max=255, message="Registered company must be %(max)d characters or fewer" ) ])
class EditSupplierCompanyRegistrationNumberForm(FlaskForm): companies_house_number = DMStripWhitespaceStringField( 'Companies House number', default='', validators=[ Optional(), Regexp( r'^([0-9]{2}|[A-Za-z]{2})[0-9]{6}$', message= "You must provide a valid 8 character Companies House number.") ]) other_company_registration_number = DMStripWhitespaceStringField( 'Other company registration number', default='', validators=[ Optional(), Length( max=255, message= "You must provide a registration number under 256 characters.") ]) def validate(self): # Admin must supply one or other field # Admin cannot supply both fields valid = True if not super(EditSupplierCompanyRegistrationNumberForm, self).validate(): valid = False if self.other_company_registration_number.data and self.companies_house_number.data: self.companies_house_number.errors.append( 'You must provide only one of either a Companies House number or overseas registration number.' ) valid = False if not self.companies_house_number.data and not self.other_company_registration_number.data: self.companies_house_number.errors.append( 'You must provide an answer.') valid = False return valid
class EditSupplierRegisteredNameForm(FlaskForm): registered_company_name = DMStripWhitespaceStringField( 'Registered company name', validators=[ InputRequired( message="You must provide a registered company name."), Length( max=255, message= "You must provide a registered company name under 256 characters." ) ])
class EmailDomainForm(FlaskForm): new_buyer_domain = DMStripWhitespaceStringField( "Add a buyer email domain", hint="For example, police.uk", validators=[ validators.DataRequired( message="The domain field can not be empty."), NotInDomainSuffixBlacklistValidator( message= "Cannot use this domain suffix: ‘%(matched_suffix)s’ domains are publicly purchasable" ), ], )
class LoginForm(FlaskForm): email_address = DMStripWhitespaceStringField( 'Email address', id="input-email_address", hint=EMAIL_LOGIN_HINT, validators=[ DataRequired(message=EMAIL_EMPTY_ERROR_MESSAGE), Regexp(EMAIL_REGEX, message=EMAIL_INVALID_ERROR_MESSAGE) ]) password = PasswordField( 'Password', id="input-password", validators=[DataRequired(message=LOGIN_PASSWORD_EMPTY_ERROR_MESSAGE)])
class EditAdminUserForm(FlaskForm): edit_admin_name = DMStripWhitespaceStringField( 'Name', validators=[DataRequired(message="You must provide a name.")]) edit_admin_permissions = DMRadioField( 'Permissions', options=ADMIN_ROLES, ) status_choices = [ ("True", "Active"), ("False", "Suspended"), ] edit_admin_status = DMRadioField('Status', choices=status_choices)
class InviteAdminForm(FlaskForm): email_address = DMStripWhitespaceStringField( "Email address", validators=[ validators.DataRequired( message='You must provide an email address'), validators.Email(message='Please enter a valid email address'), AdminEmailAddressValidator( message='The email address must belong to an approved domain'), UserAccountDoesntAlreadyExistValidator( "This email address already has a user account associated with it" ), ]) role = DMRadioField( "Permissions", validators=[ validators.InputRequired(message='You must choose a permission') ], options=ADMIN_ROLES, )
class CreateUserForm(FlaskForm): name = DMStripWhitespaceStringField( 'Your name', id="input_name", validators=[ DataRequired(message="Enter your name"), Length(min=1, max=255, message="Your name must be between 1 and 255 characters") ]) phone_number = StringField( 'Phone number (optional)', id="input_phone_number", validators=[ Regexp( "^$|^\\+?([\\d\\s()-]){9,20}$", message= ("Enter a phone number, like 01632 960 001, +44 0808 157 0192 or (020)-7946-0001" )) ]) password = PasswordField( 'Password', id="input_password", validators=[ DataRequired(message="Enter a password"), Length( min=PASSWORD_MIN_LENGTH, max=PASSWORD_MAX_LENGTH, message=PASSWORD_LENGTH_ERROR_MESSAGE, ), NotInPasswordBlacklist(message=PASSWORD_BLACKLISTED_ERROR_MESSAGE), ]) def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.phone_number.hint = PHONE_NUMBER_HINT self.password.hint = PASSWORD_HINT
class AskClarificationQuestionForm(FlaskForm): """Form for a supplier to ask a clarification question about a given brief.""" clarification_question = DMStripWhitespaceStringField( "Ask a question about ‘{brief[title]}’", question_advice=(""" <p class="govuk-body">Your question will be published with the buyer’s answer by {submission_deadline}.</p> <p class="govuk-body">All questions and answers will be posted on the Digital Marketplace. Your company name won’t be visible.</p> <p class="govuk-body">You shouldn’t include any confidential information in your question.</p> <p class="govuk-body"> Read more about <a class="govuk-link" href="{guidance_url}">how supplier questions are managed</a>. </p> """), validators=[ validators.DataRequired(message='Enter your question'), validators.Length( max=5000, message='Your question must be 5000 characters or fewer'), validators.Regexp( regex="^$|(^(?:\\S+\\s+){0,99}\\S+$)", message='Your question must be 100 words or fewer') ], widget=DMTextArea(max_length_in_words=100), ) def __init__(self, brief, *args, **kwargs): super().__init__(*args, **kwargs) self.clarification_question.question = self.clarification_question.question.format( brief=brief) self.clarification_question.question_advice = Markup( self.clarification_question.question_advice.format( submission_deadline=dateformat( brief['clarificationQuestionsPublishedBy']), guidance_url= "https://www.gov.uk/guidance/how-to-answer-supplier-questions-about-your-digital-outcomes-and-specialists-requirements", # noqa ))