Exemplo n.º 1
0
def firearms_capture_serial_numbers(number_of_items):
    if isinstance(number_of_items, str):
        try:
            number_of_items = int(number_of_items)
        except ValueError:
            number_of_items = 0
    elif number_of_items is None:
        number_of_items = 0

    questions = [
        HiddenField("capture_serial_numbers_step", True),
        HiddenField("number_of_items", number_of_items),
        Label(text=f"Number of items: {number_of_items}"),
    ]

    input_fields = [
        Group(
            id="serial_number_input_field_group",
            components=[Label(text=f"{i+1}"), TextInput(name=f"serial_number_input_{i}")],
            classes=["lite-input-with-label"],
        )
        for i in range(number_of_items)
    ]

    questions.append(GroupWithLabel(id="serial_numbers", components=input_fields))

    return Form(
        title="Enter the serial numbers for this product",
        description="Enter one serial number in every row",
        questions=questions,
        default_button_name="Save and continue",
    )
Exemplo n.º 2
0
def firearms_act_confirmation_form():
    return Form(
        title=CreateGoodForm.FirearmGood.FirearmsActCertificate.TITLE,
        questions=[
            HiddenField("section_certificate_step", True),
            Label(CreateGoodForm.FirearmGood.FirearmsActCertificate.FIREARMS_ACT),
            Label(
                id="section-1-link",
                text=linkify(
                    CreateGoodForm.FirearmGood.FirearmsActCertificate.SECTION_ONE_LINK,
                    name=CreateGoodForm.FirearmGood.FirearmsActCertificate.SECTION_ONE,
                ),
            ),
            Label(
                id="section-2-link",
                text=linkify(
                    CreateGoodForm.FirearmGood.FirearmsActCertificate.SECTION_TWO_LINK,
                    name=CreateGoodForm.FirearmGood.FirearmsActCertificate.SECTION_TWO,
                ),
            ),
            Label(
                id="section-5-link",
                text=linkify(
                    CreateGoodForm.FirearmGood.FirearmsActCertificate.SECTION_FIVE_LINK,
                    name=CreateGoodForm.FirearmGood.FirearmsActCertificate.SECTION_FIVE,
                ),
            ),
            RadioButtons(
                title="",
                name="is_covered_by_firearm_act_section_one_two_or_five",
                options=[
                    Option(
                        key=True,
                        value=CreateGoodForm.FirearmGood.FirearmsActCertificate.YES,
                        components=[
                            TextInput(
                                title=CreateGoodForm.FirearmGood.FirearmsActCertificate.SECTION_CERTIFICATE_NUMBER,
                                description="",
                                name="section_certificate_number",
                                optional=False,
                            ),
                            DateInput(
                                title=CreateGoodForm.FirearmGood.FirearmsActCertificate.EXPIRY_DATE,
                                description=CreateGoodForm.FirearmGood.FirearmsActCertificate.EXPIRY_DATE_HINT,
                                prefix="section_certificate_date_of_expiry",
                                name="section_certificate_date_of_expiry",
                            ),
                        ],
                    ),
                    Option(key=False, value=CreateGoodForm.FirearmGood.FirearmsActCertificate.NO),
                ],
            ),
        ],
    )
Exemplo n.º 3
0
def upload_firearms_act_certificate_form(section, filename, back_link):
    return Form(
        title=f"Attach your Firearms Act 1968 {section} certificate",
        description="The file must be smaller than 50MB",
        questions=[
            HiddenField("firearms_certificate_uploaded", False),
            FileUpload(),
            HiddenField("uploaded_file_name", filename),
            TextInput(
                title=CreateGoodForm.FirearmGood.FirearmsActCertificate.SECTION_CERTIFICATE_NUMBER,
                description="",
                name="section_certificate_number",
                optional=False,
            ),
            DateInput(
                title=CreateGoodForm.FirearmGood.FirearmsActCertificate.EXPIRY_DATE,
                description=CreateGoodForm.FirearmGood.FirearmsActCertificate.EXPIRY_DATE_HINT,
                prefix="section_certificate_date_of_expiry",
                name="section_certificate_date_of_expiry",
            ),
            Label(text="Or"),
            Checkboxes(
                name="section_certificate_missing",
                options=[Option(key="True", value=f"I do not have a Firearms Act 1968 {section} certificate",)],
            ),
            TextArea(
                title="Provide a reason why you do not have a certificate",
                name="section_certificate_missing_reason",
                optional=False,
            ),
        ],
        back_link=back_link,
        buttons=[Button("Save and continue", "submit")],
        javascript_imports={"/javascripts/add-good.js"},
    )
Exemplo n.º 4
0
def no_open_general_licence_form(open_general_licence_type, selected_entry,
                                 selected_country):
    return Form(
        title=OpenGeneralLicenceQuestions.NoOpenGeneralLicencesAvailable.TITLE.
        format(open_general_licence_type.name.lower()),
        description=OpenGeneralLicenceQuestions.NoOpenGeneralLicencesAvailable.
        DESCRIPTION,
        questions=[
            *[
                Label(
                    x.format(open_general_licence_type.name.lower(),
                             selected_entry, selected_country))
                for x in OpenGeneralLicenceQuestions.
                NoOpenGeneralLicencesAvailable.INFORMATION.split("\n")
            ],
            Link(
                OpenGeneralLicenceQuestions.NoOpenGeneralLicencesAvailable.
                APPLY_FOR_A_LICENCE_LINK,
                reverse("apply_for_a_licence:start"),
                classes=["govuk-body", "govuk-link--no-visited-state"],
            ),
            Link(
                OpenGeneralLicenceQuestions.NoOpenGeneralLicencesAvailable.
                RETURN_TO_ACCOUNT_HOME_LINK,
                reverse("core:home"),
                classes=["govuk-body", "govuk-link--no-visited-state"],
            ),
        ],
        buttons=[],
    )
Exemplo n.º 5
0
def document_grading_form(request, good_id):
    select_options = get_document_missing_reasons(request)[0]["reasons"]

    return Form(
        title=DocumentSensitivityForm.TITLE,
        description=DocumentSensitivityForm.DESCRIPTION,
        questions=[
            RadioButtons(
                name="has_document_to_upload",
                options=[
                    Option(key="yes", value=DocumentSensitivityForm.Options.YES),
                    Option(
                        key="no",
                        value=DocumentSensitivityForm.Options.NO,
                        components=[
                            Label(text=DocumentSensitivityForm.ECJU_HELPLINE),
                            Select(
                                name="missing_document_reason",
                                title=DocumentSensitivityForm.LABEL,
                                options=select_options,
                            ),
                        ],
                    ),
                ],
            ),
        ],
        back_link=BackLink(DocumentSensitivityForm.BACK_BUTTON, reverse_lazy("goods:good", kwargs={"pk": good_id})),
        default_button_name=DocumentSensitivityForm.SUBMIT_BUTTON,
    )
def MOD_questions(application_type=None):
    return FormGroup([
        Form(
            title=MODQuestions.WhatAreYouApplyingFor.TITLE,
            description=MODQuestions.WhatAreYouApplyingFor.DESCRIPTION,
            questions=[
                RadioButtons(
                    name="application_type",
                    options=[
                        Option(
                            key=CaseTypes.F680,
                            value=MODQuestions.WhatAreYouApplyingFor.
                            PERMISSION_TITLE,
                            description=MODQuestions.WhatAreYouApplyingFor.
                            PERMISSION_DESCRIPTION,
                        ),
                        Option(
                            key=CaseTypes.EXHC,
                            value=MODQuestions.WhatAreYouApplyingFor.
                            EXHIBITION_CLEARANCE_TITLE,
                            description=MODQuestions.WhatAreYouApplyingFor.
                            EXHIBITION_CLEARANCE_DESCRIPTION,
                        ),
                        Option(
                            key=CaseTypes.GIFT,
                            value=MODQuestions.WhatAreYouApplyingFor.
                            GIFTING_CLEARANCE_TITLE,
                            description=MODQuestions.WhatAreYouApplyingFor.
                            GIFTING_CLEARANCE_DESCRIPTION,
                        ),
                    ],
                ),
            ],
            default_button_name=generic.CONTINUE,
            back_link=BackLink(MODQuestions.WhatAreYouApplyingFor.BACK,
                               reverse_lazy("apply_for_a_licence:start")),
        ),
        conditional(
            application_type == CaseTypes.F680,
            Form(
                title=MODQuestions.ConfirmationStatement.TITLE,
                questions=[
                    Label(paragraph) for paragraph in
                    MODQuestions.ConfirmationStatement.DESCRIPTION.split("\n")
                ],
                default_button_name=generic.CONFIRM_AND_CONTINUE,
            ),
        ),
        reference_name_form(),
    ])
Exemplo n.º 7
0
def open_licence_return_form_group():
    return FormGroup([
        Form(
            title=OpenReturnsHelpPage.TITLE,
            questions=[
                Label(OpenReturnsHelpPage.DESCRIPTION),
                DetailComponent(OpenReturnsHelpPage.FORMATTING_HELP_LINK,
                                OpenReturnsHelpPage.FORMATTING_HELP_DETAILS),
            ],
            default_button_name=OpenReturnsHelpPage.BUTTON,
            back_link=BackLink(OpenReturnsHelpPage.BACK,
                               reverse_lazy("core:home")),
        ),
        Form(
            title=OpenReturnsForm.Year.TITLE,
            description=OpenReturnsForm.Year.DESCRIPTION,
            questions=[
                Select(
                    title=OpenReturnsForm.Year.FIELD_TITLE,
                    description=OpenReturnsForm.Year.FIELD_DESCRIPTION,
                    name="year",
                    options=get_years(),
                )
            ],
            default_button_name=OpenReturnsForm.Year.BUTTON,
        ),
        Form(
            title=OpenReturnsForm.Upload.TITLE,
            description=OpenReturnsForm.Upload.DESCRIPTION,
            questions=[
                FileUpload(),
                Label(OpenReturnsForm.Upload.ExampleTable.HEADING),
                Custom("components/spreadsheet.html"),
            ],
            default_button_name=OpenReturnsForm.Upload.BUTTON,
        ),
    ])
Exemplo n.º 8
0
def select_flags(request, team_id, flags_to_include, flags_to_exclude,
                 is_editing):

    flags_checkboxes = [
        Option(flag["id"],
               flag["name"],
               data_attribute=get_flag_details_html(flag))
        for flag in get_flags_for_team_of_level(
            request, level="", team_id=team_id, include_system_flags=True)
    ]

    return Form(
        title=Forms.FLAGS if not is_editing else "Edit flags",
        questions=[
            HiddenField(name="flags_to_include",
                        value=",".join(flags_to_include)),
            HiddenField(name="flags_to_exclude",
                        value=",".join(flags_to_exclude)),
            HTMLBlock("<div id='routing-rules-flags-details'></div>"),
            Label(id="condition-label", text="Apply the routing rule to:"),
            RadioButtons(
                title="",
                name="routing_rules_flags_condition",
                options=[
                    Option(key="contain_selected_flags",
                           value="Cases that contain selected flags"),
                    Option(key="doesnot_contain_selected_flags",
                           value="Cases that do not contain selected flags"),
                ],
            ),
            Filter(),
            Checkboxes(
                name="flags[]",
                options=flags_checkboxes,
                import_custom_js=[
                    "/javascripts/filter-checkbox-list-flags.js"
                ],
            ),
        ],
        buttons=[
            Button("Save and continue", "submit", id="save_and_continue"),
            Button("Add another condition",
                   "",
                   ButtonStyle.SECONDARY,
                   id="add-another-condition",
                   link="#"),
        ],
        javascript_imports={"/javascripts/routing-rules-flags.js"},
    )
Exemplo n.º 9
0
def document_grading_form(back_url):
    return Form(
        title=DocumentSensitivityForm.TITLE,
        questions=[
            RadioButtons(
                name="is_document_sensitive",
                options=[
                    Option(
                        key="yes",
                        value=DocumentSensitivityForm.Options.YES,
                        components=[Label(text=DocumentSensitivityForm.ECJU_HELPLINE)],
                    ),
                    Option(key="no", value=DocumentSensitivityForm.Options.NO,),
                ],
            ),
        ],
        back_link=BackLink("Back", back_url),
        default_button_name=DocumentSensitivityForm.SUBMIT_BUTTON,
    )
Exemplo n.º 10
0
def electronic_warfare_form():
    return Form(
        caption=F680Questions.CAPTION,
        title=F680Questions.EWRequirement.TITLE,
        questions=[
            RadioButtons(
                name="electronic_warfare_requirement",
                options=[
                    Option(
                        key=True,
                        value="Yes",
                        components=[
                            Label(text=F680Questions.EWRequirement.ATTACHMENT)
                        ]),
                    Option(key=False, value="No"),
                ],
            )
        ],
        default_button_name=generic.SAVE_AND_CONTINUE,
    )
Exemplo n.º 11
0
def attach_document_form(application_id, strings, back_link, is_optional):
    return Form(
        strings.TITLE,
        strings.DESCRIPTION,
        [
            FileUpload(optional=is_optional),
            TextArea(title=strings.DESCRIPTION_FIELD_TITLE,
                     optional=True,
                     name="description"),
        ],
        back_link=BackLink(
            strings.BACK, reverse_lazy(back_link,
                                       kwargs={"pk": application_id})),
        footer_label=Label(
            'Or <a id="return_to_application" href="' + str(
                reverse_lazy("applications:task_list",
                             kwargs={"pk": application_id})) +
            '" class="govuk-link govuk-link--no-visited-state">' +
            strings.SAVE_AND_RETURN_LATER + "</a> " + strings.ATTACH_LATER),
    )
Exemplo n.º 12
0
def deny_licence_form(queue_pk, case_id, is_open_licence, nlr):
    if nlr:
        description = lite_content.lite_internal_frontend.advice.FinaliseLicenceForm.NLR_DESCRIPTION
    else:
        description = lite_content.lite_internal_frontend.advice.FinaliseLicenceForm.REFUSE_DESCRIPTION

    return Form(
        title=lite_content.lite_internal_frontend.advice.FinaliseLicenceForm.FINALISE_TITLE,
        questions=[Label(description), HiddenField(name="action", value="refuse")],
        back_link=conditional(
            is_open_licence,
            BackLink(
                url=reverse_lazy("cases:finalise_goods_countries", kwargs={"queue_pk": queue_pk, "pk": case_id}),
                text=lite_content.lite_internal_frontend.advice.FinaliseLicenceForm.Actions.BACK_TO_DECISION_MATRIX_BUTTON,
            ),
            BackLink(
                url=reverse_lazy("cases:case", kwargs={"queue_pk": queue_pk, "pk": case_id, "tab": "final-advice"}),
                text=lite_content.lite_internal_frontend.advice.FinaliseLicenceForm.Actions.BACK_TO_ADVICE_BUTTON,
            ),
        ),
    )
Exemplo n.º 13
0
def footer_label(application_id):
    return Label('Or <a class="govuk-link" href="' + reverse_lazy(
        "applications:task_list", kwargs={"pk": str(application_id)}) +
                 '">Or return to application overview</a>')
Exemplo n.º 14
0
def register_triage():
    from core.views import RegisterAnOrganisationTriage

    return FormGroup(
        [
            Form(
                title=RegisterAnOrganisation.Landing.TITLE,
                questions=[
                    Label(RegisterAnOrganisation.Landing.DESCRIPTION),
                    Label(RegisterAnOrganisation.Landing.DESCRIPTION_2),
                    Label(RegisterAnOrganisation.Landing.SUMMARY_LIST_HEADER),
                    List(StartPage.BULLET_POINTS, type=List.ListType.BULLETED),
                    Label(StartPage.NOTICE, classes=["govuk-inset-text"]),
                ],
                default_button_name=RegisterAnOrganisation.Landing.BUTTON,
                default_button_style=ButtonStyle.START,
                back_link=Breadcrumbs([*[BackLink(x[0], x[1]) for x in StartPage.BREADCRUMBS], BackLink("LITE", None)]),
            ),
            Form(
                title=RegisterAnOrganisation.CommercialOrIndividual.TITLE,
                description=RegisterAnOrganisation.CommercialOrIndividual.DESCRIPTION,
                caption="Step 1 of 4",
                questions=[
                    RadioButtons(
                        name="type",
                        options=[
                            Option(
                                key="commercial",
                                value=RegisterAnOrganisation.CommercialOrIndividual.COMMERCIAL,
                                description=RegisterAnOrganisation.CommercialOrIndividual.COMMERCIAL_DESCRIPTION,
                            ),
                            Option(
                                key="individual",
                                value=RegisterAnOrganisation.CommercialOrIndividual.INDIVIDUAL,
                                description=RegisterAnOrganisation.CommercialOrIndividual.INDIVIDUAL_DESCRIPTION,
                            ),
                        ],
                    )
                ],
                default_button_name=generic.CONTINUE,
            ),
            Form(
                title=RegisterAnOrganisation.WhereIsYourOrganisationBased.TITLE,
                description=RegisterAnOrganisation.WhereIsYourOrganisationBased.DESCRIPTION,
                caption="Step 2 of 4",
                questions=[
                    RadioButtons(
                        name="location",
                        options=[
                            Option(
                                key=RegisterAnOrganisationTriage.Locations.UNITED_KINGDOM,
                                value=RegisterAnOrganisation.WhereIsYourOrganisationBased.IN_THE_UK,
                                description=RegisterAnOrganisation.WhereIsYourOrganisationBased.IN_THE_UK_DESCRIPTION,
                            ),
                            Option(
                                key=RegisterAnOrganisationTriage.Locations.ABROAD,
                                value=RegisterAnOrganisation.WhereIsYourOrganisationBased.OUTSIDE_THE_UK,
                                description=RegisterAnOrganisation.WhereIsYourOrganisationBased.OUTSIDE_THE_UK_DESCRIPTION,
                            ),
                        ],
                    )
                ],
                default_button_name=generic.CONTINUE,
            ),
        ]
    )
Exemplo n.º 15
0
 def test_no_user_inputs_no_title_label(self):
     form = Form(questions=[BackLink(), Label("abc"), HiddenField("abc", "123"),])
     self.assertIsNone(form.single_form_element)
Exemplo n.º 16
0
def declaration_form(application_id):
    return Form(
        title=strings.declaration.Declaration.TITLE,
        questions=[
            HiddenField(name="submit_declaration", value=True),
            # Terms and conditions
            Label("<b>" + strings.declaration.TermsAndConditions.TITLE +
                  "</b>"),
            Label(strings.declaration.TermsAndConditions.PARAGRAPH_ONE),
            Label(strings.declaration.TermsAndConditions.PARAGRAPH_TWO),
            # Licence conditions
            Label("<b>" + strings.declaration.LicenceConditions.TITLE + "<b>"),
            # Authorisation
            Label("<u>" +
                  strings.declaration.LicenceConditions.Authorisation.TITLE +
                  "</u>"),
            Label(strings.declaration.LicenceConditions.Authorisation.
                  PARAGRAPH_ONE),
            HTMLBlock(
                "<ol class='govuk-list govuk-list--number'>"
                "<ol type='a'>"
                "<li>" +
                strings.declaration.LicenceConditions.Authorisation.OPTION_A +
                "</li>"
                "<li>" +
                strings.declaration.LicenceConditions.Authorisation.OPTION_B +
                "</li>"
                "</ol>"
                "</ol>"),
            Label(strings.declaration.LicenceConditions.Authorisation.
                  PARAGRAPH_TWO),
            # Conditions
            Label("<u>" +
                  strings.declaration.LicenceConditions.Conditions.TITLE +
                  "</u>"),
            HTMLBlock("<ol class='govuk-list govuk-list--number'>"
                      "<li>" + strings.declaration.LicenceConditions.
                      Conditions.LIST_ITEM_ONE + "</li>"
                      "<li>" + strings.declaration.LicenceConditions.
                      Conditions.LIST_ITEM_TWO + "</li>"
                      "<li>" + strings.declaration.LicenceConditions.
                      Conditions.LIST_ITEM_THREE + "<ol type='a'>"
                      "<li>" + strings.declaration.LicenceConditions.
                      Conditions.LIST_ITEM_THREE_A + "</li>"
                      "<li>" + strings.declaration.LicenceConditions.
                      Conditions.LIST_ITEM_THREE_B + "</li>"
                      "<li>" + strings.declaration.LicenceConditions.
                      Conditions.LIST_ITEM_THREE_C + "</li>"
                      "</ol>"
                      "</li>"
                      "<li>" + strings.declaration.LicenceConditions.
                      Conditions.LIST_ITEM_FOUR + "</li>"
                      "<li>" + strings.declaration.LicenceConditions.
                      Conditions.LIST_ITEM_FIVE + "<ol type='a'>"
                      "<li>" + strings.declaration.LicenceConditions.
                      Conditions.LIST_ITEM_FIVE_A + "</li>"
                      "<li>" + strings.declaration.LicenceConditions.
                      Conditions.LIST_ITEM_FIVE_B + "<ol type='i'>"
                      "<li>" + strings.declaration.LicenceConditions.
                      Conditions.LIST_ITEM_FIVE_B_I + "</li>"
                      "<li>" + strings.declaration.LicenceConditions.
                      Conditions.LIST_ITEM_FIVE_B_II + "</li>"
                      "</ol>"
                      "</li>"
                      "<li>" + strings.declaration.LicenceConditions.
                      Conditions.LIST_ITEM_FIVE_C + "<ol type='i'>"
                      "<li>" + strings.declaration.LicenceConditions.
                      Conditions.LIST_ITEM_FIVE_C_I + "</li>"
                      "<li>" + strings.declaration.LicenceConditions.
                      Conditions.LIST_ITEM_FIVE_C_II + "</li>"
                      "<li>" + strings.declaration.LicenceConditions.
                      Conditions.LIST_ITEM_FIVE_C_III + "</li>"
                      "</ol>"
                      "</li>"
                      "<li>" + strings.declaration.LicenceConditions.
                      Conditions.LIST_ITEM_FIVE_D + "</li>"
                      "</ol>"
                      "</li>"
                      "<li>" + strings.declaration.LicenceConditions.
                      Conditions.LIST_ITEM_SIX + "</li>"
                      "<li>" + strings.declaration.LicenceConditions.
                      Conditions.LIST_ITEM_SEVEN + "</li>"
                      "</ol>"),
            # Standard conditions
            Label("<u>" + strings.declaration.LicenceConditions.
                  StandardConditions.TITLE + "</u>"),
            List(
                strings.declaration.LicenceConditions.StandardConditions.
                BULLET_POINTS,
                type=List.ListType.NUMBERED,
            ),
            # General notes
            Label("<u>" +
                  strings.declaration.LicenceConditions.GeneralNotes.TITLE +
                  "</u>"),
            Label(
                strings.declaration.LicenceConditions.GeneralNotes.LINK_TEXT),
            Link(
                name="general-notes-link",
                text=strings.declaration.LicenceConditions.GeneralNotes.LINK,
                address=strings.declaration.LicenceConditions.GeneralNotes.
                LINK,
            ),
            Label(strings.declaration.LicenceConditions.GeneralNotes.
                  PARAGRAPH_ONE),
            Label(strings.declaration.LicenceConditions.GeneralNotes.
                  PARAGRAPH_TWO),
            Label(strings.declaration.LicenceConditions.GeneralNotes.
                  PARAGRAPH_THREE),
            # Declaration
            Label("<b>" + strings.declaration.Declaration.TITLE + "</b>"),
            Label(strings.declaration.Declaration.PARAGRAPH_ONE + "<br><br>" +
                  strings.declaration.Declaration.PARAGRAPH_TWO + "<br><br>" +
                  strings.declaration.Declaration.PARAGRAPH_THREE +
                  "<br><br>" + strings.declaration.Declaration.PARAGRAPH_FOUR),
            # User input
            RadioButtons(
                name="agreed_to_foi",
                title=strings.declaration.FOI.TITLE,
                options=[
                    Option(True, strings.declaration.FOI.AGREE_TO_FOI),
                    Option(False, strings.declaration.FOI.DISAGREE_TO_FOI),
                ],
                classes=["govuk-radios--inline"],
            ),
            Checkboxes(
                name="agreed_to_declaration",
                title=strings.declaration.Declaration.RADIO_TITLE,
                options=[
                    Option(
                        "True",
                        strings.declaration.Declaration.AGREE_TO_DECLARATION,
                        data_attribute="agreed_to_declaration",
                    )
                ],
                classes=["govuk-checkboxes--small"],
            ),
        ],
        default_button_name=strings.declaration.Declaration.BUTTON_TITLE,
        back_link=BackLink(
            strings.declaration.Declaration.BACK,
            reverse_lazy("applications:summary", kwargs={"pk":
                                                         application_id}),
        ),
    )
Exemplo n.º 17
0
def site_records_location(request, in_uk=True, is_editing=False):
    return Form(
        caption="" if is_editing else "Step 3 of 4",
        title=strings.sites.AddSiteForm.SiteRecords.SiteInUK.TITLE
        if in_uk else strings.sites.AddSiteForm.SiteRecords.SiteNotInUK.TITLE,
        description=strings.sites.AddSiteForm.SiteRecords.DESCRIPTION,
        questions=[
            *conditional(
                in_uk,
                [
                    RadioButtons(
                        name="site_records_stored_here",
                        options=[
                            Option(key=True, value=strings.YES),
                            Option(
                                key=False,
                                value=strings.sites.AddSiteForm.SiteRecords.
                                SiteInUK.NO_RECORDS_HELD_ELSEWHERE,
                                components=[
                                    RadioButtons(
                                        name="site_records_located_at",
                                        options=[
                                            Option(site["id"], site["name"])
                                            for site in filter_sites_in_the_uk(
                                                get_sites(
                                                    request,
                                                    request.user.organisation))
                                        ],
                                    ),
                                    Label(
                                        'If the site isn\'t listed, you need to <a id="site-dashboard" href="'
                                        + str(
                                            reverse_lazy(
                                                "organisation:sites:sites")) +
                                        '" class="govuk-link govuk-link--no-visited-state">'
                                        + "add the site" + "</a> " +
                                        "from your account dashboard."),
                                ],
                            ),
                        ],
                    ),
                ],
                [
                    HiddenField("site_records_stored_here", False),
                    Label(
                        'If the site isn\'t listed, you need to <a id="site-dashboard" href="'
                        + str(reverse_lazy("organisation:sites:sites")) +
                        '" class="govuk-link govuk-link--no-visited-state">' +
                        "add the site" + "</a> " +
                        "from your account dashboard."),
                    RadioButtons(
                        name="site_records_located_at",
                        options=[
                            Option(site["id"], site["name"])
                            for site in filter_sites_in_the_uk(
                                get_sites(request, request.user.organisation))
                        ],
                    ),
                ],
            ),
            HiddenField("validate_only", True),
            HiddenField("records_located_step", True),
        ],
        default_button_name=generic.CONTINUE,
    )
Exemplo n.º 18
0
 def test_single_user_input_with_other_questions_has_title_label(self):
     name = "Test"
     form = Form(questions=[BackLink(), Label("abc"), TextInput(name), HiddenField("abc", "123"),])
     self.assertEqual(form.single_form_element.name, name)
Exemplo n.º 19
0
def footer_label(application_id):
    url = reverse("applications:task_list", kwargs={"pk": str(application_id)})
    return Label(f'Or <a class="govuk-link" href="{url}">return to application overview</a>')
Exemplo n.º 20
0
def open_general_licence_forms(request, **kwargs):
    open_general_licence_type = OpenGeneralExportLicenceTypes.get_by_acronym(
        kwargs["ogl"])
    control_list_entries = get_control_list_entries(request, True)
    countries = get_countries(request, True)
    selected_entry = request.POST.get("control_list_entry")
    selected_country = next((country.value for country in countries
                             if country.key == request.POST.get("country")),
                            "")
    open_general_licences = get_open_general_licences(
        request,
        convert_to_options=True,
        case_type=open_general_licence_type.id,
        control_list_entry=request.POST.get("control_list_entry"),
        country=request.POST.get("country"),
        status="active",
    )
    sites = get_sites(request, request.user.organisation, True)
    selected_open_general_licence = {}
    if request.POST.get("open_general_licence"):
        selected_open_general_licence = get_open_general_licence(
            request, request.POST.get("open_general_licence"))

    if open_general_licence_type.acronym == OpenGeneralExportLicenceTypes.open_general_export_licence.acronym:
        back_link_url = reverse("apply_for_a_licence:export_licence_questions")
    elif open_general_licence_type.acronym == OpenGeneralExportLicenceTypes.open_general_transhipment_licence.acronym:
        back_link_url = reverse("apply_for_a_licence:transhipment_questions")
    else:
        back_link_url = reverse(
            "apply_for_a_licence:trade_control_licence_questions")

    return FormGroup([
        Form(
            title=OpenGeneralLicenceQuestions.ControlListEntry.TITLE,
            description=OpenGeneralLicenceQuestions.ControlListEntry.
            DESCRIPTION,
            questions=[
                AutocompleteInput(name="control_list_entry",
                                  options=control_list_entries)
            ],
            default_button_name=generic.CONTINUE,
            back_link=BackLink(url=back_link_url),
        ),
        Form(
            title=OpenGeneralLicenceQuestions.Country.TITLE,
            description=OpenGeneralLicenceQuestions.Country.DESCRIPTION,
            questions=[AutocompleteInput(name="country", options=countries)],
            default_button_name=generic.CONTINUE,
        ),
        *conditional(
            open_general_licences,
            [
                Form(
                    title=OpenGeneralLicenceQuestions.OpenGeneralLicences.
                    TITLE.format(open_general_licence_type.name.lower()),
                    questions=[
                        Label(
                            OpenGeneralLicenceQuestions.OpenGeneralLicences.
                            DESCRIPTION.format(
                                open_general_licence_type.name.lower(),
                                selected_entry, selected_country)),
                        Label(OpenGeneralLicenceQuestions.OpenGeneralLicences.
                              HELP_TEXT),
                        RadioButtons(
                            name="open_general_licence",
                            options=[
                                *open_general_licences,
                                Option(
                                    "",
                                    OpenGeneralLicenceQuestions.
                                    OpenGeneralLicences.NONE_OF_THE_ABOVE,
                                    show_or=True,
                                ),
                            ],
                        ),
                    ],
                    default_button_name=generic.CONTINUE,
                )
            ],
            [
                no_open_general_licence_form(open_general_licence_type,
                                             selected_entry, selected_country)
            ],
        ),
        conditional(
            selected_open_general_licence,
            Form(
                caption=conditional(
                    selected_open_general_licence.get("registration_required"),
                    OpenGeneralLicenceQuestions.OpenGeneralLicenceDetail.
                    CAPTION,
                ),
                title=open_general_licence_type.name + " (" +
                selected_open_general_licence.get("name", "") + ")",
                questions=[
                    conditional(
                        not selected_open_general_licence.get(
                            "registration_required"),
                        WarningBanner(
                            "warning",
                            OpenGeneralLicenceQuestions.
                            OpenGeneralLicenceDetail.NO_REGISTRATION_REQUIRED.
                            format(open_general_licence_type.name.lower()),
                        ),
                    ),
                    HiddenField("application_type",
                                open_general_licence_type.acronym.lower()),
                    *conditional(
                        selected_open_general_licence.get(
                            "registration_required"),
                        [
                            Heading(
                                OpenGeneralLicenceQuestions.
                                OpenGeneralLicenceDetail.Summary.HEADING,
                                HeadingStyle.S),
                            Custom(
                                "components/ogl-step-list.html",
                                data={
                                    **selected_open_general_licence, "sites":
                                    sites
                                },
                            ),
                            Custom("components/ogl-warning.html"),
                            Checkboxes(
                                name="confirmation[]",
                                options=[
                                    Option(
                                        "read", OpenGeneralLicenceQuestions.
                                        Conditions.READ),
                                    Option(
                                        "comply", OpenGeneralLicenceQuestions.
                                        Conditions.COMPLY),
                                ],
                            ),
                        ],
                        [],
                    ),
                ],
                buttons=[
                    conditional(
                        selected_open_general_licence.get(
                            "registration_required"),
                        Button("Register", "submit"),
                    )
                ],
            ),
            no_open_general_licence_form(open_general_licence_type,
                                         selected_entry, selected_country),
        ),
    ])
Exemplo n.º 21
0
 def test_label(self):
     label = Label(self.markdown_description)
     self.assertEqual(label.text, self.html_description)