def get_forms(self):
     if self.contacts:
         return FormGroup([
             select_template_form(self.templates, self.back_url),
             select_addressee_form(),
             edit_document_text_form(
                 {
                     "queue_pk": self.kwargs["queue_pk"],
                     "pk": self.kwargs["pk"],
                     "tpk": self.template
                 },
                 post_url="cases:generate_document_preview",
             ),
         ])
     else:
         return FormGroup([
             select_template_form(self.templates, self.back_url),
             edit_document_text_form(
                 {
                     "queue_pk": self.kwargs["queue_pk"],
                     "pk": self.kwargs["pk"],
                     "tpk": self.template
                 },
                 post_url="cases:generate_document_preview",
             ),
         ])
Example #2
0
def new_party_form_group(request,
                         application,
                         strings,
                         back_url,
                         clearance_options=None,
                         is_end_user=False):
    back_link = BackLink(
        PartyTypeForm.BACK_LINK,
        reverse_lazy(back_url, kwargs={"pk": application["id"]}))

    forms = [
        party_type_form(application, strings.TITLE, strings.BUTTON, back_link),
        party_name_form(strings.NAME_FORM_TITLE, strings.BUTTON),
        party_website_form(strings.WEBSITE_FORM_TITLE, strings.BUTTON),
    ]

    if clearance_options:
        forms.extend(clearance_level_forms(clearance_options, strings.BUTTON))

    # Exclude the UK if end user on standard transhipment
    is_gb_excluded = application.case_type["reference"][
        "key"] == CaseTypes.SITL and is_end_user
    forms.append(
        party_address_form(request,
                           strings.ADDRESS_FORM_TITLE,
                           strings.SUBMIT_BUTTON,
                           is_gb_excluded=is_gb_excluded))

    if is_end_user:
        forms.append(
            party_signatory_name_form("Signatory name", "Save and continue"))

    return FormGroup(forms)
Example #3
0
def export_licence_questions(request,
                             application_type,
                             goodstype_category=None):
    forms = [export_type_form()]

    if application_type == CaseTypes.OIEL:
        forms.append(goodstype_category_form())

    if application_type != CaseTypes.OGEL and goodstype_category not in [
            "media", "cryptographic"
    ]:
        forms.append(export_permanency_form(application_type))

    if application_type != CaseTypes.OGEL:
        forms.append(reference_name_form())

    if application_type == CaseTypes.SIEL:
        forms.append(told_by_an_official_form())

    if goodstype_category in [
            GoodsTypeCategory.MILITARY, GoodsTypeCategory.UK_CONTINENTAL_SHELF
    ]:
        forms.append(firearms_form())

    return FormGroup(forms)
def third_party_forms(request,
                      application,
                      strings,
                      back_url,
                      clearance_options=None):
    form_options = role_option_list.copy()
    if application["case_type"]["sub_type"]["key"] != F680:
        form_options.pop("customer")
    export_type = application.get("export_type")
    if not export_type or export_type.get("key") == PERMANENT:
        del form_options["additional_end_user"]

    options = [Option(key, value) for key, value in form_options.items()]
    options.append(
        Option("other",
               PartyForm.Options.OTHER,
               show_or=True,
               components=[TextInput(name="role_other")]))
    forms = [
        _third_party_role_form(application, strings.ROLE_TITLE, strings.BUTTON,
                               options, back_url),
        party_type_form(application, strings.TYPE_TITLE, strings.BUTTON,
                        BackLink()),
        party_name_form(strings.NAME_FORM_TITLE, strings.BUTTON),
        party_website_form(strings.WEBSITE_FORM_TITLE, strings.BUTTON),
    ]

    if clearance_options:
        forms.extend(clearance_level_forms(clearance_options, strings.BUTTON))

    forms.append(
        party_address_form(request, strings.ADDRESS_FORM_TITLE,
                           strings.SUBMIT_BUTTON))

    return FormGroup(forms)
Example #5
0
def register_a_commercial_organisation_group(request, location):
    from exporter.core.views import RegisterAnOrganisationTriage

    is_in_uk = location == RegisterAnOrganisationTriage.Locations.UNITED_KINGDOM

    return FormGroup([
        Form(
            title=RegisterAnOrganisation.Commercial.TITLE,
            description=RegisterAnOrganisation.Commercial.DESCRIPTION,
            caption="Step 3 of 4",
            questions=[
                HiddenField("location", location),
                TextInput(
                    title=RegisterAnOrganisation.Commercial.NAME,
                    description=RegisterAnOrganisation.Commercial.
                    NAME_DESCRIPTION,
                    name="name",
                ),
                TextInput(
                    title=RegisterAnOrganisation.Commercial.EORI_NUMBER,
                    description=RegisterAnOrganisation.Commercial.
                    EORI_NUMBER_DESCRIPTION,
                    short_title=RegisterAnOrganisation.Commercial.
                    EORI_NUMBER_SHORT_TITLE,
                    name="eori_number",
                    optional=not is_in_uk,
                ),
                TextInput(
                    title=RegisterAnOrganisation.Commercial.SIC_NUMBER,
                    description=RegisterAnOrganisation.Commercial.
                    SIC_NUMBER_DESCRIPTION,
                    short_title=RegisterAnOrganisation.Commercial.
                    SIC_NUMBER_SHORT_TITLE,
                    name="sic_number",
                    optional=not is_in_uk,
                ),
                TextInput(
                    title=RegisterAnOrganisation.Commercial.VAT_NUMBER,
                    description=RegisterAnOrganisation.Commercial.
                    VAT_NUMBER_DESCRIPTION,
                    short_title=RegisterAnOrganisation.Commercial.
                    VAT_NUMBER_SHORT_TITLE,
                    name="vat_number",
                    optional=not is_in_uk,
                ),
                TextInput(
                    title=RegisterAnOrganisation.Commercial.CRN_NUMBER,
                    description=RegisterAnOrganisation.Commercial.
                    CRN_NUMBER_DESCRIPTION,
                    short_title=RegisterAnOrganisation.Commercial.
                    CRN_NUMBER_SHORT_TITLE,
                    name="registration_number",
                    optional=not is_in_uk,
                ),
            ],
            default_button_name=generic.CONTINUE,
        ),
        site_form(request, False, location),
    ])
Example #6
0
def temporary_export_details_form():
    return FormGroup(
        [
            provide_export_details_form(TemporaryExportDetails.TEMPORARY_EXPORT_DETAILS_CAPTION),
            is_temp_direct_control_form(TemporaryExportDetails.TEMPORARY_EXPORT_DETAILS_CAPTION),
            proposed_product_return_date_form(TemporaryExportDetails.TEMPORARY_EXPORT_DETAILS_CAPTION),
        ]
    )
Example #7
0
def new_external_location_form(request, application_type=None, location_type=None):
    return FormGroup(
        forms=[
            conditional(
                (application_type in [CaseTypes.SICL, CaseTypes.OICL]), location_type_form(request, application_type),
            ),
            new_location_form(request, application_type, location_type),
        ]
    )
Example #8
0
def questions_forms():
    return FormGroup([
        expedited_form(),
        foreign_technology_form(),
        locally_manufactured_form(),
        mtcr_form(),
        electronic_warfare_form(),
        uk_service_equipment_form(),
        uk_service_equipment_type_form(),
        prospect_value_form(),
    ], )
Example #9
0
def add_firearm_good_form_group(request, is_pv_graded: bool = None, draft_pk: str = None):
    return FormGroup(
        [
            add_goods_questions(request, draft_pk),
            conditional(is_pv_graded, pv_details_form(request)),
            group_two_product_type_form(),
            firearm_ammunition_details_form(),
            firearms_act_confirmation_form(),
            identification_markings_form(),
        ]
    )
def trade_control_licence_questions(request):
    return FormGroup([
        application_type_form(),
        *conditional(
            request.POST.get("application_type") != CaseTypes.OGTCL,
            [
                reference_name_form(),
                activity_form(request),
                product_category_form(request)
            ],
            [],
        ),
    ])
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(),
    ])
Example #12
0
def add_firearm_good_form_group(request,
                                is_pv_graded: bool = None,
                                draft_pk: str = None):
    control_list_entries = get_control_list_entries(request,
                                                    convert_to_options=True)
    return FormGroup([
        add_goods_questions(control_list_entries, draft_pk),
        conditional(is_pv_graded, pv_details_form(request)),
        group_two_product_type_form(),
        firearm_year_of_manufacture_details_form(),
        firearm_calibre_details_form(),
        firearms_act_confirmation_form(),
        identification_markings_form(),
    ])
Example #13
0
def good_on_application_form_group(request, is_preexisting, good,
                                   sub_case_type, draft_pk):
    # is_preexisting are only asked if user is adding a preexisting good from their product list
    # but not if the good being added to the application is a new good created as part of this same flow
    firearm_type = None
    if good.get("firearm_details"):
        firearm_type = good["firearm_details"]["type"]["key"]

    is_firearm_core = firearm_type and firearm_type in FIREARM_AMMUNITION_COMPONENT_TYPES
    return FormGroup([
        conditional(is_preexisting, identification_markings_form(draft_pk)),
        conditional(is_preexisting,
                    firearm_year_of_manufacture_details_form()),
        unit_quantity_value(request, good, sub_case_type, draft_pk),
        conditional(is_preexisting and is_firearm_core,
                    firearms_act_confirmation_form()),
    ])
Example #14
0
def add_good_form_group(
    request,
    is_pv_graded: bool = None,
    is_software_technology: bool = None,
    is_firearm: bool = None,
    is_firearms_core: bool = None,
    is_firearms_accessory: bool = None,
    is_firearms_software_tech: bool = None,
    draft_pk: str = None,
    base_form_back_link: str = None,
):
    control_list_entries = get_control_list_entries(request,
                                                    convert_to_options=True)
    return FormGroup([
        conditional(not settings.FEATURE_FLAG_ONLY_ALLOW_FIREARMS_PRODUCTS,
                    product_category_form(request)),
        conditional(
            request.POST.get("item_category") == PRODUCT_CATEGORY_FIREARM
            or settings.FEATURE_FLAG_ONLY_ALLOW_FIREARMS_PRODUCTS,
            group_two_product_type_form(back_link=base_form_back_link),
        ),
        conditional(is_firearms_core and draft_pk,
                    identification_markings_form()),
        conditional(is_firearms_core,
                    firearms_sporting_shotgun_form(request.POST.get("type"))),
        add_goods_questions(control_list_entries, draft_pk),
        conditional(is_pv_graded, pv_details_form(request)),
        # only ask if adding to a draft application
        conditional(is_firearm and bool(draft_pk),
                    firearm_year_of_manufacture_details_form()),
        conditional(is_firearm,
                    firearm_replica_form(request.POST.get("type"))),
        conditional(is_firearms_core, firearm_calibre_details_form()),
        conditional(is_firearms_core and bool(draft_pk),
                    firearms_act_confirmation_form()),
        conditional(
            is_firearms_software_tech,
            software_technology_details_form(request,
                                             request.POST.get("type"))),
        conditional(is_firearms_accessory or is_firearms_software_tech,
                    product_military_use_form(request)),
        conditional(is_firearms_accessory, product_component_form(request)),
        conditional(is_firearms_accessory or is_firearms_software_tech,
                    product_uses_information_security(request)),
    ])
 def get_forms(self):
     self.back_url = reverse_lazy("cases:finalise_documents",
                                  kwargs={
                                      "queue_pk": self.kwargs["queue_pk"],
                                      "pk": self.kwargs["pk"]
                                  })
     return FormGroup([
         select_template_form(self.templates, back_url=self.back_url),
         edit_document_text_form(
             {
                 "queue_pk": self.kwargs["queue_pk"],
                 "pk": self.kwargs["pk"],
                 "tpk": self.template,
                 "decision_key": self.kwargs["decision_key"],
             },
             post_url="cases:finalise_document_preview",
         ),
     ])
Example #16
0
def register_hmrc_organisation_forms():
    return FormGroup(
        [
            Form(
                title="Register an HMRC organisation",
                questions=[
                    HiddenField(name="type", value="hmrc"),
                    TextInput(title="Name of HMRC organisation", name="name"),
                    TextInput(title=RegisterAnOrganisation.NAME_OF_SITE, name="site.name"),
                    Heading("Where are they based?", HeadingStyle.M),
                    *address_questions(None, "site.address."),
                ],
                default_button_name="Continue",
            ),
            create_admin_user_form(),
        ],
        show_progress_indicators=True,
    )
Example #17
0
def end_use_details_form(application, request):
    is_eu_military = request.POST.get(
        "is_eu_military", "").lower() == "true" or application.is_eu_military
    caption = ""

    if application.sub_type == STANDARD:
        caption = StandardApplicationTaskList.END_USE_DETAILS
    elif application.sub_type == OPEN:
        caption = OpenApplicationTaskList.END_USE_DETAILS

    return FormGroup([
        intended_end_use_form(caption),
        is_military_end_use_controls_form(caption),
        is_informed_wmd_form(caption),
        is_suspected_wmd_form(caption),
        conditional(application.sub_type == STANDARD,
                    is_eu_military_form(caption)),
        conditional(is_eu_military, is_compliant_limitations_eu_form(caption)),
    ])
Example #18
0
def routing_rule_form_group(request,
                            additional_rules,
                            team_id,
                            is_editing=False,
                            select_team=False):
    return FormGroup([
        conditional(
            select_team,
            select_a_team(request),
        ),
        initial_routing_rule_questions(request, team_id, is_editing),
        conditional("case_types" in additional_rules,
                    select_case_type(request)),
        conditional("flags" in additional_rules,
                    select_flags(request, team_id)),
        conditional("country" in additional_rules, select_country(request)),
        conditional("users" in additional_rules,
                    select_team_member(request, team_id)),
    ])
def transhipment_questions(request):
    return FormGroup([
        Form(
            title=TranshipmentQuestions.TranshipmentLicenceQuestion.TITLE,
            description=TranshipmentQuestions.TranshipmentLicenceQuestion.
            DESCRIPTION,
            questions=[
                RadioButtons(
                    name="application_type",
                    options=[
                        Option(
                            key=CaseTypes.OGTL,
                            value=TranshipmentQuestions.
                            TranshipmentLicenceQuestion.
                            OPEN_GENERAL_TRANSHIPMENT_LICENCE,
                            description=TranshipmentQuestions.
                            TranshipmentLicenceQuestion.
                            OPEN_GENERAL_TRANSHIPMENT_LICENCE_DESCRIPTION,
                        ),
                        Option(
                            key=CaseTypes.SITL,
                            value=TranshipmentQuestions.
                            TranshipmentLicenceQuestion.STANDARD_LICENCE,
                            description=TranshipmentQuestions.
                            TranshipmentLicenceQuestion.
                            STANDARD_LICENCE_DESCRIPTION,
                        ),
                    ],
                ),
            ],
            default_button_name=generic.CONTINUE,
            back_link=BackLink(
                TranshipmentQuestions.TranshipmentLicenceQuestion.BACK,
                reverse_lazy("apply_for_a_licence:start")),
        ),
        *conditional(
            request.POST.get("application_type") != CaseTypes.OGTL,
            [reference_name_form(),
             told_by_an_official_form()],
            [],
        ),
    ])
Example #20
0
def add_good_form_group(
    request,
    is_pv_graded: bool = None,
    is_software_technology: bool = None,
    is_firearms: bool = None,
    draft_pk: str = None,
):
    return FormGroup(
        [
            product_category_form(request),
            add_goods_questions(request, draft_pk),
            conditional(is_pv_graded, pv_details_form(request)),
            conditional(is_software_technology, software_technology_details_form(request)),
            conditional(not is_firearms, product_military_use_form(request)),
            conditional(not is_software_technology and not is_firearms, product_component_form(request)),
            conditional(not is_firearms, product_uses_information_security(request)),
            conditional(is_firearms, group_two_product_type_form()),
            conditional(is_firearms, firearm_ammunition_details_form()),
            conditional(is_firearms, firearms_act_confirmation_form()),
            conditional(is_firearms, identification_markings_form()),
        ]
    )
Example #21
0
def routing_rule_form_group(request,
                            additional_rules,
                            team_id,
                            flags_to_include,
                            flags_to_exclude,
                            is_editing=False,
                            select_team=False):
    additional_rules = additional_rules or []

    return FormGroup([
        initial_routing_rule_questions(request, select_team, team_id,
                                       is_editing),
        conditional("case_types" in additional_rules,
                    select_case_type(request)),
        conditional(
            "flags" in additional_rules,
            select_flags(request, team_id, flags_to_include, flags_to_exclude,
                         is_editing),
        ),
        conditional("country" in additional_rules, select_country(request)),
        conditional("users" in additional_rules,
                    select_team_member(request, team_id)),
    ])
Example #22
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,
        ),
    ])
Example #23
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,
            ),
        ]
    )
def export_licence_questions(request,
                             application_type,
                             goodstype_category=None):
    should_display_firearms_question = goodstype_category in [
        GoodsTypeCategory.MILITARY,
        GoodsTypeCategory.UK_CONTINENTAL_SHELF,
    ]

    return FormGroup([
        Form(
            title=ExportLicenceQuestions.ExportLicenceQuestion.TITLE,
            description=ExportLicenceQuestions.ExportLicenceQuestion.
            DESCRIPTION,
            questions=[
                RadioButtons(
                    name="application_type",
                    options=[
                        Option(
                            key=CaseTypes.OGEL,
                            value=ExportLicenceQuestions.ExportLicenceQuestion.
                            OPEN_GENERAL_EXPORT_LICENCE,
                            description=ExportLicenceQuestions.
                            ExportLicenceQuestion.
                            OPEN_GENERAL_EXPORT_LICENCE_DESCRIPTION,
                        ),
                        Option(
                            key=CaseTypes.SIEL,
                            value=ExportLicenceQuestions.ExportLicenceQuestion.
                            STANDARD_LICENCE,
                            description=ExportLicenceQuestions.
                            ExportLicenceQuestion.STANDARD_LICENCE_DESCRIPTION,
                        ),
                        Option(
                            key=CaseTypes.OIEL,
                            value=ExportLicenceQuestions.ExportLicenceQuestion.
                            OPEN_LICENCE,
                            description=ExportLicenceQuestions.
                            ExportLicenceQuestion.OPEN_LICENCE_DESCRIPTION,
                        ),
                    ],
                ),
                DetailComponent(
                    InitialApplicationQuestionsForms.OpeningQuestion.
                    HELP_WITH_CHOOSING_A_LICENCE,
                    InitialApplicationQuestionsForms.OpeningQuestion.
                    HELP_WITH_CHOOSING_A_LICENCE_CONTENT,
                ),
            ],
            default_button_name=generic.CONTINUE,
            back_link=BackLink(
                ExportLicenceQuestions.ExportLicenceQuestion.BACK,
                reverse_lazy("apply_for_a_licence:start")),
        ),
        *conditional(application_type == CaseTypes.OIEL,
                     [goodstype_category_form()], []),
        *conditional(
            application_type != CaseTypes.OGEL
            and goodstype_category not in ["media", "cryptographic"],
            [
                Form(
                    title=ExportLicenceQuestions.ExportType.TITLE,
                    description=ExportLicenceQuestions.ExportType.DESCRIPTION,
                    questions=[
                        RadioButtons(
                            name="export_type",
                            options=[
                                Option(
                                    "temporary", ExportLicenceQuestions.
                                    ExportType.TEMPORARY),
                                Option(
                                    "permanent", ExportLicenceQuestions.
                                    ExportType.PERMANENT),
                            ],
                        ),
                    ],
                    default_button_name=generic.CONTINUE if application_type
                    == CaseTypes.SIEL else generic.SAVE_AND_CONTINUE,
                ),
            ],
            [],
        ),
        *conditional(application_type != CaseTypes.OGEL,
                     [reference_name_form()], []),
        *conditional(application_type == CaseTypes.SIEL,
                     [told_by_an_official_form()], []),
        *conditional(should_display_firearms_question, [firearms_form()], []),
    ])
Example #25
0
def register_organisation_forms(request):
    """
    Handles flow for registering an organisation
    Diverges based on organisation type (individual or commercial), location answer
    also changes compulsory fields
    """
    is_individual = request.POST.get("type") == "individual"
    in_uk = request.POST.get("location") == "united_kingdom"

    return FormGroup(
        [
            Form(
                title=RegisterAnOrganisation.CommercialOrIndividual.TITLE,
                description=RegisterAnOrganisation.CommercialOrIndividual.
                DESCRIPTION,
                questions=[
                    RadioButtons(
                        name="type",
                        options=[
                            Option(
                                key="commercial",
                                value=RegisterAnOrganisation.
                                CommercialOrIndividual.COMMERCIAL_TITLE,
                                description=RegisterAnOrganisation.
                                CommercialOrIndividual.COMMERCIAL_DESCRIPTION,
                            ),
                            Option(
                                key="individual",
                                value=RegisterAnOrganisation.
                                CommercialOrIndividual.INDIVIDUAL_TITLE,
                                description=RegisterAnOrganisation.
                                CommercialOrIndividual.INDIVIDUAL_DESCRIPTION,
                            ),
                        ],
                    )
                ],
                back_link=BackLink(RegisterAnOrganisation.BACK_LINK,
                                   reverse("organisations:organisations")),
                default_button_name=strings.CONTINUE,
            ),
            Form(
                title=RegisterAnOrganisation.WhereIsTheExporterBased.TITLE,
                description=RegisterAnOrganisation.WhereIsTheExporterBased.
                DESCRIPTION,
                questions=[
                    RadioButtons(
                        name="location",
                        options=[
                            Option(
                                key="united_kingdom",
                                value=RegisterAnOrganisation.
                                WhereIsTheExporterBased.IN_THE_UK_TITLE,
                                description=RegisterAnOrganisation.
                                WhereIsTheExporterBased.IN_THE_UK_DESCRIPTION,
                            ),
                            Option(
                                key="abroad",
                                value=RegisterAnOrganisation.
                                WhereIsTheExporterBased.ABROAD_TITLE,
                                description=RegisterAnOrganisation.
                                WhereIsTheExporterBased.ABROAD_DESCRIPTION,
                            ),
                        ],
                    )
                ],
                default_button_name=strings.CONTINUE,
            ),
            conditional(is_individual, register_individual_form(in_uk),
                        register_commercial_form(in_uk)),
            create_default_site_form(request, in_uk),
            conditional(
                not is_individual,
                create_admin_user_form(),
            ),
        ],
        show_progress_indicators=True,
    )
Example #26
0
def application_copy_form(application_type=None):
    return FormGroup(forms=[
        reference_name_form(),
        conditional((
            application_type == STANDARD), told_by_an_official_form()),
    ])
Example #27
0
def copy_end_user_advisory_form(request, individual, commercial):
    return FormGroup([
        Form(
            title="End user details",
            questions=[
                TextInput(title="Organisation name", name="end_user.name"),
                conditional(
                    individual,
                    TextInput(title="Email address", name="contact_email")),
                conditional(
                    individual,
                    TextInput(title="Telephone number",
                              name="contact_telephone")),
                conditional(
                    commercial,
                    TextInput(title="Nature of the end user's business",
                              name="nature_of_business"),
                ),
                conditional(
                    not individual,
                    TextInput(title="Contact's name", name="contact_name")),
                conditional(
                    not individual,
                    TextInput(title="Job title", name="contact_job_title"),
                ),
                conditional(
                    not individual,
                    TextInput(title="Email address", name="contact_email"),
                ),
                conditional(
                    not individual,
                    TextInput(title="Telephone number",
                              name="contact_telephone"),
                ),
                TextInput(title="Website address",
                          name="end_user.website",
                          optional=True),
                TextArea(
                    title="Address",
                    description=
                    "The delivery address or registered office for the person "
                    "receiving the products",
                    name="end_user.address",
                ),
                country_question(countries=get_countries(request, True),
                                 prefix="end_user."),
                HiddenField("validate_only", True),
            ],
            back_link=BackLink(
                strings.end_users.CopyEndUserAdvisoryForm.BACK_LINK,
                reverse_lazy("end_users:end_users")),
            default_button_name=strings.CONTINUE,
        ),
        Form(
            title="More information about the end user",
            questions=[
                TextArea(
                    title="What's your reasoning behind this query?",
                    optional=True,
                    name="reasoning",
                    extras={
                        "max_length": 2000,
                    },
                ),
                TextArea(
                    title=
                    "Is there any other information you can provide about the end user?",
                    description=
                    "This may help provide a quicker response from ECJU.",
                    optional=True,
                    name="note",
                    extras={"max_length": 2000},
                ),
                HiddenField("validate_only", False),
            ],
        ),
    ])
Example #28
0
def new_site_forms(request):
    in_uk = request.POST.get("location", "").lower() == "united_kingdom"
    sites = []
    if request.POST.get("address.postcode"):
        sites = get_sites(request,
                          request.user.organisation,
                          postcode=request.POST.get("address.postcode"))

    return FormGroup([
        Form(
            caption="Step 1 of 4",
            title=AddSiteForm.WhereIsYourSiteBased.TITLE,
            description=AddSiteForm.WhereIsYourSiteBased.DESCRIPTION,
            questions=[
                RadioButtons(
                    name="location",
                    options=[
                        Option(
                            key="united_kingdom",
                            value=AddSiteForm.WhereIsYourSiteBased.IN_THE_UK,
                            description=AddSiteForm.WhereIsYourSiteBased.
                            IN_THE_UK_DESCRIPTION,
                        ),
                        Option(
                            key="abroad",
                            value=AddSiteForm.WhereIsYourSiteBased.
                            OUTSIDE_THE_UK,
                            description=AddSiteForm.WhereIsYourSiteBased.
                            OUTSIDE_THE_UK_DESCRIPTION,
                        ),
                    ],
                )
            ],
            default_button_name=generic.CONTINUE,
            back_link=BackLink(AddSiteForm.BACK_LINK,
                               reverse_lazy("organisation:sites:sites")),
        ),
        Form(
            caption="Step 2 of 4",
            title=AddSiteForm.Details.TITLE,
            description=AddSiteForm.Details.DESCRIPTION,
            questions=[
                TextInput(title=AddSiteForm.Details.NAME, name="name"),
                Heading(
                    conditional(in_uk, AddSiteForm.Details.ADDRESS_HEADER_UK,
                                AddSiteForm.Details.ADDRESS_HEADER_ABROAD),
                    HeadingStyle.M,
                ),
                *conditional(
                    in_uk,
                    address_questions(None),
                    foreign_address_questions(
                        get_countries(request, True, ["GB"])),
                ),
                HiddenField("validate_only", True),
            ],
            default_button_name=generic.CONTINUE,
        ),
        conditional(
            sites,
            Form(
                title=AddSiteForm.Postcode.TITLE,
                description=AddSiteForm.Postcode.DESCRIPTION.format(", ".join(
                    site["name"] for site in sites)),
                questions=[
                    HiddenField(name="are_you_sure", value=None),
                    RadioButtons(
                        name="are_you_sure",
                        title=AddSiteForm.Postcode.CONTROL_TITLE,
                        options=[
                            Option(True, AddSiteForm.Postcode.YES),
                            Option(False, AddSiteForm.Postcode.NO),
                        ],
                    ),
                ],
                default_button_name=generic.CONTINUE,
            ),
        ),
        site_records_location(request, in_uk),
        Form(
            caption="Step 4 of 4",
            title=AddSiteForm.AssignUsers.TITLE,
            description=AddSiteForm.AssignUsers.DESCRIPTION,
            questions=[
                Filter(placeholder=AddSiteForm.AssignUsers.FILTER),
                Checkboxes(
                    name="users[]",
                    options=get_organisation_users(
                        request,
                        request.user.organisation,
                        {
                            "disable_pagination": True,
                            "exclude_permission": Permissions.ADMINISTER_SITES
                        },
                        True,
                    ),
                    filterable=True,
                ),
                HiddenField("validate_only", False),
            ],
            default_button_name=generic.SAVE_AND_CONTINUE,
        ),
    ])
Example #29
0
def apply_for_an_end_user_advisory_form(request, individual, commercial):
    return FormGroup(
        [
            Form(
                title="Confirm how the products will be used",
                questions=[
                    HTMLBlock(
                        "<ul class='govuk-list govuk-list--bullet'>"
                        "<li class='govuk-!-margin-bottom-5'>I've checked the <a class='govuk-link' href='https://scsanctions.un.org/fop/fop?xml=htdocs/resources/xml/en/consolidated.xml&xslt=htdocs/resources/xsl/en/consolidated.xsl'>UN Security Council Committee's list</a> and the products will not be used by anyone named on this list</li>"  # noqa
                        "<li class='govuk-!-margin-bottom-5'>I've checked the <a class='govuk-link' href='https://permissions-finder.service.trade.gov.uk/'>Department for International Trade's list of controlled goods</a> and the products are not controlled</li>"  # noqa
                        "<li class='govuk-!-margin-bottom-5'>I've previously not been informed by the Export Control Joint Unit (ECJU) that the products could be used to make chemical, biological or nuclear weapons</li>"  # noqa
                        "<li>I do not have any reason to suspect that the products could be used to make chemical, biological or nuclear weapons</li>"  # noqa
                        "</ul>"),
                ],
                default_button_name="Confirm and continue",
            ),
            Form(
                title="Select the type of end user",
                questions=[
                    RadioButtons(
                        title="",
                        name="end_user.sub_type",
                        options=[
                            Option("government", "Government organisation"),
                            Option("commercial", "Commercial organisation"),
                            Option("individual", "An individual"),
                            Option("other", "Other", show_or=True),
                        ],
                    ),
                ],
                default_button_name="Continue",
            ),
            Form(
                title="End user details",
                questions=[
                    TextInput(title="Organisation name", name="end_user.name"),
                    conditional(
                        individual,
                        TextInput(title="Email address",
                                  name="contact_email")),
                    conditional(
                        individual,
                        TextInput(title="Telephone number",
                                  name="contact_telephone")),
                    conditional(
                        commercial,
                        TextInput(title="Nature of the end user's business",
                                  name="nature_of_business"),
                    ),
                    conditional(
                        not individual,
                        TextInput(title="Contact's name",
                                  name="contact_name")),
                    conditional(
                        not individual,
                        TextInput(title="Job title", name="contact_job_title"),
                    ),
                    conditional(
                        not individual,
                        TextInput(title="Email address", name="contact_email"),
                    ),
                    conditional(
                        not individual,
                        TextInput(title="Telephone number",
                                  name="contact_telephone"),
                    ),
                    TextInput(title="Website address",
                              name="end_user.website",
                              optional=True),
                    TextArea(
                        title="Address",
                        description=
                        "The delivery address or registered office for the person "
                        "receiving the products.",
                        name="end_user.address",
                    ),
                    country_question(countries=get_countries(request, True),
                                     prefix="end_user."),
                    HiddenField("validate_only", True),
                ],
                default_button_name="Continue",
            ),
            Form(
                title="More information about the end user",
                questions=[
                    TextArea(
                        title="What's your reasoning behind this query?",
                        optional=True,
                        name="reasoning",
                        extras={"max_length": 2000},
                    ),
                    TextArea(
                        title=
                        "Is there any other information you can provide about the end user?",
                        description=
                        "This may help provide a quicker response from ECJU.",
                        optional=True,
                        name="note",
                        extras={"max_length": 2000},
                    ),
                    HiddenField("validate_only", False),
                ],
            ),
        ],
        show_progress_indicators=True,
    )
Example #30
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),
        ),
    ])