Пример #1
0
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 DidYouAwardAContractForm(FlaskForm):
    YES = 'yes'
    NO = 'no'
    STILL_ASSESSING = 'still-assessing'

    did_you_award_a_contract = DMRadioField(
        "Did you award a contract?",
        id="input-did_you_award_a_contract",
        validators=[InputRequired(message="Select if you have awarded your contract")],
        options=[
            {'value': YES, 'label': 'Yes'},
            {'value': NO, 'label': 'No'},
            {'value': STILL_ASSESSING, 'label': 'We are still assessing services'},
        ])
class CompanyOrganisationSizeForm(FlaskForm):
    OPTIONS = [
        {
            "value":
            "micro",
            "label":
            "Micro",
            "description":
            "Under 10 employees and 2 million euros or less in either annual turnover or balance "
            "sheet total",
        },
        {
            "value":
            "small",
            "label":
            "Small",
            "description":
            "Under 50 employees and 10 million euros or less in either annual turnover or balance "
            "sheet total",
        },
        {
            "value":
            "medium",
            "label":
            "Medium",
            "description":
            "Under 250 employees and either 50 million euros or less in either annual turnover or "
            "43 million euros or less in annual balance sheet total",
        },
        {
            "value":
            "large",
            "label":
            "Large",
            "description":
            "250 or more employees and either over 50 million euros in annual turnover or over 43 "
            "million euros in balance sheet total",
        },
    ]

    organisation_size = DMRadioField(
        "What size is your organisation?",
        hint=
        "This information will be used to report on the number of contracts that go"
        " to small and medium sized enterprises (SMEs).",
        validators=[
            InputRequired(message="You must choose an organisation size.")
        ],
        options=OPTIONS)
class WhichServiceWonTheContractForm(FlaskForm):
    which_service_won_the_contract = DMRadioField(
        "Which service won the contract?",
        id="input-which_service_won_the_contract",
        validators=[InputRequired(message="Select the service that won the contract")],
    )

    def __init__(self, services, *args, **kwargs):
        super(WhichServiceWonTheContractForm, self).__init__(*args, **kwargs)

        self.which_service_won_the_contract.options = [{
            "label": service["data"]["serviceName"],
            "value": service["id"],
            "hint": service["supplier"]["name"],
        } for service in services['services']]
class WhyDidYouNotAwardForm(FlaskForm):
    why_did_you_not_award_the_contract = DMRadioField(
        "Why didn’t you award a contract?",
        id="input-why_did_you_not_award_the_contract",
        options=[
            {
                "label": "The work has been cancelled",
                "value": "work_cancelled",
                "hint": "For example, because you no longer have the budget",
            },
            {
                "label": "There were no suitable services",
                "value": "no_suitable_services",
                "hint": "The services in your search results did not meet your requirements",
            },
        ],
        validators=[InputRequired(message="Select a reason why you didn't award a contract")]
    )
Пример #6
0
class LegalAuthorityForm(FlaskForm):
    HEADING = 'Do you have the legal authority to sign on behalf of your company?'
    HINT = "For example, you are a director or company secretary."
    OPTIONS = [
        {
            "value": "yes",
            "label": "Yes",
        },
        {
            "value": "no",
            "label": "No",
        },
    ]
    legal_authority = DMRadioField(
        HEADING,
        hint=HINT,
        validators=[InputRequired(message="Select yes if you have the legal authority"
                                          " to sign on behalf of your company")],
        options=OPTIONS)
class CreateProjectForm(FlaskForm):
    save_search_selection = DMRadioField(
        id="input-save_search_selection",
        validators=[
            InputRequired("Select where to save your search result")
        ]
    )

    def __init__(self, projects, **kwargs):
        super().__init__(**kwargs)

        self.save_search_selection.options = [{
            "label": project["name"] or f"Untitled project {project['id']}",
            "value": str(project["id"]),
        } for project in projects]
        self.save_search_selection.options.append({
            "label": "Save a new search",
            "value": "new_search",
        })
Пример #8
0
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 CompanyTradingStatusForm(FlaskForm):
    OPTIONS = [
        {
            'value': 'limited company (LTD)',
            'label': 'limited company (LTD)',
        },
        {
            'value': 'limited liability company (LLC)',
            'label': 'limited liability company (LLC)',
        },
        {
            'value': 'public limited company (PLC)',
            'label': 'public limited company (PLC)',
        },
        {
            'value': 'limited liability partnership (LLP)',
            'label': 'limited liability partnership (LLP)',
        },
        {
            'value': 'sole trader',
            'label': 'sole trader',
        },
        {
            'value': 'public body',
            'label': 'public body',
        },
        {
            'value': 'other',
            'label': 'other',
        },
    ]

    trading_status = DMRadioField(
        "What’s your trading status?",
        hint=
        "This information will be used to find out about the types of companies on frameworks.",
        validators=[
            InputRequired(message="You must choose a trading status.")
        ],
        options=OPTIONS)