def party_address_form(request, title, button, is_gb_excluded=False):
    return Form(
        title=title,
        questions=[
            TextArea("address", "Address"),
            country_question(
                countries=get_countries(request, True, ["GB"])
                if is_gb_excluded else get_countries(request, True),
                prefix="",
            ),
        ],
        default_button_name=button,
    )
def site_form(request, is_individual, location):
    from core.views import RegisterAnOrganisationTriage

    is_in_uk = location == RegisterAnOrganisationTriage.Locations.UNITED_KINGDOM

    return Form(
        title=conditional(
            not is_individual,
            conditional(
                is_in_uk, RegisterAnOrganisation.Headquarters.TITLE, RegisterAnOrganisation.Headquarters.TITLE_FOREIGN,
            ),
            conditional(
                is_in_uk,
                RegisterAnOrganisation.Headquarters.TITLE_INDIVIDUAL,
                RegisterAnOrganisation.Headquarters.TITLE_INDIVIDUAL_FOREIGN,
            ),
        ),
        description=RegisterAnOrganisation.Headquarters.DESCRIPTION,
        caption="Step 4 of 4",
        questions=[
            TextInput(
                title=RegisterAnOrganisation.Headquarters.NAME,
                description=RegisterAnOrganisation.Headquarters.NAME_DESCRIPTION,
                name="site.name",
            ),
            *conditional(
                is_in_uk,
                address_questions(None, "site.address."),
                foreign_address_questions(get_countries(request, True, ["GB"]), "site.address."),
            ),
        ],
        default_button_name=generic.CONTINUE,
    )
def new_location_form(request, application_type, location_type):
    exclude = []
    if application_type in [CaseTypes.SITL, CaseTypes.SICL, CaseTypes.OICL]:
        exclude.append("GB")

    countries = get_countries(request, True, exclude)

    return Form(
        title=NewLocationForm.TITLE,
        description=NewLocationForm.DESCRIPTION,
        questions=[
            HiddenField(name="external_locations", value=""),
            TextInput(name="name", title=NewLocationForm.Name.TITLE),
            TextArea(
                name="address",
                title=conditional(
                    location_type == LocationType.SEA_BASED,
                    NewLocationForm.Address.SEA_BASED_TITLE,
                    NewLocationForm.Address.TITLE,
                ),
                description=conditional(
                    application_type == CaseTypes.SITL,
                    NewLocationForm.Address.SITL_DESCRIPTION,
                    conditional(
                        location_type == LocationType.SEA_BASED,
                        NewLocationForm.Address.SEA_BASED_DESCRIPTION,
                        NewLocationForm.Address.DESCRIPTION,
                    ),
                ),
            ),
            conditional(location_type != LocationType.SEA_BASED,
                        country_question(prefix="", countries=countries)),
        ],
        default_button_name=strings.SAVE_AND_CONTINUE,
    )
Beispiel #4
0
    def get(self, request, *args, **kwargs):
        open_general_licences = get_open_general_licences(
            request, **request.GET)
        control_list_entries = get_control_list_entries(request, True)
        countries = get_countries(request, True)

        filters = FiltersBar([
            HiddenField("status", request.GET.get("status", "active")),
            TextInput(name="name", title="name"),
            Select(name="case_type",
                   title="type",
                   options=OpenGeneralExportLicences.as_options()),
            AutocompleteInput(name="control_list_entry",
                              title="control list entry",
                              options=control_list_entries),
            AutocompleteInput(name="country",
                              title="country",
                              options=countries),
        ])

        context = {
            "filters": filters,
            "tab": request.GET.get("status", "active"),
            "open_general_licences": open_general_licences,
        }
        return render(request, "open-general-licences/index.html", context)
def licences_filters(request):
    return [
        TextInput(
            name="reference",
            title=LicencesList.Filters.REFERENCE,
        ),
        AutocompleteInput(
            name="clc",
            title=LicencesList.Filters.CLC,
            options=get_control_list_entries(request, convert_to_options=True),
        ),
        AutocompleteInput(
            name="country",
            title=LicencesList.Filters.DESTINATION_COUNTRY,
            options=get_countries(request, convert_to_options=True),
        ),
        TextInput(
            name="end_user",
            title=LicencesList.Filters.DESTINATION_NAME,
        ),
        Checkboxes(
            name="active_only",
            options=[Option(key=True, value=LicencesList.Filters.ACTIVE)],
            classes=["govuk-checkboxes--small"],
        ),
    ]
def select_country(request):
    return Form(
        title=Forms.COUNTRY,
        questions=[
            AutocompleteInput(
                name="country",
                options=get_countries(request, convert_to_options=True),
            )
        ],
    )
Beispiel #7
0
    def init(self, request, **kwargs):
        self.action = post_picklist_item
        countries, _ = get_countries(request)
        flags = get_flags(request, status=FlagStatus.ACTIVE.value)
        denial_reasons = get_denial_reasons(request, False)

        self.context = {
            **countries, "flags": flags,
            "denial_reasons": denial_reasons
        }
        self.success_url = reverse_lazy(
            "picklists:picklists") + "?type=" + self.request.GET.get("type")
Beispiel #8
0
    def prettify_data(self, data):
        countries, _ = get_countries(self.request)
        countries = [
            country["name"] for country in countries["countries"]
            if country["id"] in data.get("countries", [])
        ]

        data["registration_required"] = friendly_boolean(
            data["registration_required"])
        data["control_list_entries[]"] = ", ".join(
            data.get("control_list_entries", []))
        data["countries[]"] = ", ".join(countries)
        return data
Beispiel #9
0
    def init(self, request, **kwargs):
        self.object_pk = kwargs["pk"]
        self.object = get_picklist_item(request, self.object_pk)
        self.data = self.object
        self.action = put_picklist_item
        self.success_url = reverse_lazy("picklists:picklist_item",
                                        kwargs={"pk": self.object_pk})
        self.success_message = EditPicklistItemForm.SUCCESS_MESSAGE
        countries, _ = get_countries(request)
        flags = get_flags(request, status=FlagStatus.ACTIVE.value)
        denial_reasons = get_denial_reasons(request)

        self.context = {
            **countries, "flags": flags,
            "denial_reasons": denial_reasons
        }
Beispiel #10
0
def create_default_site_form(request, in_uk):
    return Form(
        title=RegisterAnOrganisation.CREATE_DEFAULT_SITE,
        questions=[
            TextInput(title=RegisterAnOrganisation.NAME_OF_SITE,
                      name="site.name"),
            Heading(RegisterAnOrganisation.WhereIsTheExporterBased.TITLE,
                    HeadingStyle.M),
            *conditional(
                in_uk,
                address_questions(None, "site.address."),
                foreign_address_questions(get_countries(request, True, ["GB"]),
                                          "site.address."),
            ),
        ],
        default_button_name=strings.CONTINUE,
    )
def countries_form(request, application_id):
    return Form(
        title=strings.applications.DestinationForm.TITLE,
        description=strings.applications.DestinationForm.DESCRIPTION,
        questions=[
            Filter(),
            Checkboxes(
                name="countries[]",
                options=get_countries(request, True, ["GB"]),
                classes=["govuk-checkboxes--small"],
                show_select_links=True,
                filterable=True,
            ),
        ],
        default_button_name=strings.SAVE_AND_CONTINUE,
        back_link=back_to_task_list(application_id),
    )
Beispiel #12
0
def select_condition_and_flag(request, type: str):
    title = ""
    condition = []
    flags = []
    is_for_verified_goods_only = None

    if type == "Good":
        title = strings.FlaggingRules.Create.Condition_and_flag.GOOD_TITLE
        condition = TextInput(title=strings.FlaggingRules.Create.Condition_and_flag.GOOD, name="matching_value",)
        flags = get_goods_flags(request=request)
        is_for_verified_goods_only = RadioButtons(
            name="is_for_verified_goods_only",
            options=[
                Option(key=True, value=FlaggingRules.Create.Condition_and_flag.YES_OPTION),
                Option(key=False, value=FlaggingRules.Create.Condition_and_flag.NO_OPTION),
            ],
            title=FlaggingRules.Create.Condition_and_flag.GOODS_QUESTION,
        )
    elif type == "Destination":
        title = strings.FlaggingRules.Create.Condition_and_flag.DESTINATION_TITLE
        condition = AutocompleteInput(
            title=strings.FlaggingRules.Create.Condition_and_flag.DESTINATION,
            name="matching_value",
            options=get_countries(request, convert_to_options=True),
        )
        flags = get_destination_flags(request=request)
    elif type == "Case":
        title = strings.FlaggingRules.Create.Condition_and_flag.APPLICATION_TITLE
        case_type_options = [Option(option["key"], option["value"]) for option in get_case_types(request)]
        condition = Select(
            title=strings.FlaggingRules.Create.Condition_and_flag.APPLICATION,
            name="matching_value",
            options=case_type_options,
        )
        flags = get_cases_flags(request=request)

    return Form(
        title=title,
        questions=[
            condition,
            Select(title=strings.FlaggingRules.Create.Condition_and_flag.FLAG, name="flag", options=flags),
            is_for_verified_goods_only,
        ],
    )
Beispiel #13
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,
        ),
    ])
Beispiel #14
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),
        ),
    ])
Beispiel #15
0
def open_general_licence_forms(request, licence, strings):
    control_list_entries = get_control_list_entries(request)
    control_list_entries_tree = convert_dictionary_to_tree(
        group_control_list_entries_by_category(control_list_entries),
        key="rating",
        value="rating",
        exclude="is_decontrolled",
    )
    countries = get_countries(request, True)

    return FormGroup([
        Form(
            title=strings.SelectType.TITLE,
            description=strings.SelectType.DESCRIPTION,
            caption=strings.Steps.STEP_1,
            questions=[
                RadioButtons(
                    short_title="Type",
                    name="case_type",
                    options=OpenGeneralExportLicences.as_options(),
                ),
            ],
            default_button_name=generic.CONTINUE,
        ),
        Form(
            title=strings.Details.TITLE.format(licence.name.lower()),
            description=strings.Details.DESCRIPTION,
            caption=strings.Steps.STEP_2,
            questions=[
                TextArea(
                    title=strings.Details.Name.TITLE.format(
                        licence.name.lower()),
                    short_title=strings.Details.Name.SHORT_TITLE,
                    description=strings.Details.Name.DESCRIPTION,
                    name="name",
                    rows=3,
                    classes=["govuk-!-width-three-quarters"],
                    data_attributes={"licence-name": licence.name},
                ),
                TextArea(
                    title=strings.Details.Description.TITLE,
                    short_title=strings.Details.Description.SHORT_TITLE,
                    description=strings.Details.Description.DESCRIPTION,
                    name="description",
                    classes=["govuk-!-width-three-quarters"],
                    extras={"max_length": 2000},
                ),
                TextInput(
                    title=strings.Details.Link.TITLE.format(
                        licence.name.lower()),
                    short_title=strings.Details.Link.SHORT_TITLE,
                    description=strings.Details.Link.DESCRIPTION,
                    name="url",
                    classes=["govuk-!-width-three-quarters"],
                ),
                RadioButtons(
                    title=strings.Details.RequiresRegistration.TITLE.format(
                        licence.name.lower()),
                    short_title=strings.Details.RequiresRegistration.
                    SHORT_TITLE,
                    description=strings.Details.RequiresRegistration.
                    DESCRIPTION.format(licence.name.lower()),
                    name="registration_required",
                    options=[
                        Option(True, strings.Details.RequiresRegistration.YES),
                        Option(False, strings.Details.RequiresRegistration.NO),
                    ],
                    classes=["govuk-radios--inline"],
                ),
            ],
            javascript_imports={"/javascripts/new-open-general-licence.js"},
            default_button_name=generic.CONTINUE,
        ),
        Form(
            title=strings.ControlListEntries.TITLE,
            description=strings.ControlListEntries.DESCRIPTION,
            caption=strings.Steps.STEP_3,
            questions=[
                TreeView(
                    name="control_list_entries[]",
                    short_title=strings.ControlListEntries.TITLE,
                    data=control_list_entries_tree,
                )
            ],
            default_button_name=generic.CONTINUE,
        ),
        Form(
            title=strings.Countries.TITLE,
            description=strings.Countries.DESCRIPTION,
            caption=strings.Steps.STEP_4,
            questions=[
                Filter(),
                Checkboxes(
                    name="countries[]",
                    short_title=strings.Countries.SHORT_TITLE,
                    options=countries,
                    classes=["govuk-checkboxes--small"],
                    show_select_links=True,
                    filterable=True,
                ),
            ],
            default_button_name=generic.CONTINUE,
        ),
    ])
Beispiel #16
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,
    )
Beispiel #17
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),
            ],
        ),
    ])
Beispiel #18
0
def case_filters_bar(request, queue) -> FiltersBar:
    """
    Returns a FiltersBar for the case search page.
    """
    sla_sort = [
        Option("ascending",
               CasesListPage.Filters.SORT_BY_SLA_ELAPSED_ASCENDING),
        Option("descending",
               CasesListPage.Filters.SORT_BY_SLA_ELAPSED_DESCDENDING),
    ]
    sla_days = [Option(i, i) for i in range(SLA_DAYS_RANGE)]

    return FiltersBar(
        [
            TextInput(name="case_reference", title="case reference"),
            Select(name="case_type",
                   title=CasesListPage.Filters.CASE_TYPE,
                   options=[]),
            Select(name="status",
                   title=CasesListPage.Filters.CASE_STATUS,
                   options=[]),
            AutocompleteInput(
                name="case_officer",
                title=CasesListPage.Filters.CASE_OFFICER,
                options=[
                    Option("not_assigned", CasesListPage.Filters.NOT_ASSIGNED)
                ],
                deferred=True,
            ),
            AutocompleteInput(
                name="assigned_user",
                title=CasesListPage.Filters.ASSIGNED_USER,
                options=[
                    Option("not_assigned", CasesListPage.Filters.NOT_ASSIGNED)
                ],
                deferred=True,
            ),
            conditional(
                not queue["is_system_queue"],
                Checkboxes(
                    name="hidden",
                    options=[
                        Option(True,
                               CasesListPage.Filters.HIDDEN,
                               id="show-hidden-cases")
                    ],
                    classes=["govuk-checkboxes--small"],
                ),
            ),
        ],
        advanced_filters=[
            TextInput(
                name="exporter_application_reference",
                title=CasesListPage.Filters.EXPORTER_APPLICATION_REFERENCE),
            TextInput(name="organisation_name",
                      title=CasesListPage.Filters.ORGANISATION_NAME),
            TextInput(name="exporter_site_name",
                      title=CasesListPage.Filters.EXPORTER_SITE_NAME),
            TextInput(name="exporter_site_address",
                      title=CasesListPage.Filters.EXPORTER_SITE_ADDRESS),
            Select(name="team_advice_type",
                   title=CasesListPage.Filters.TEAM_ADVICE_TYPE,
                   options=[]),
            Select(name="final_advice_type",
                   title=CasesListPage.Filters.FINAL_ADVICE_TYPE,
                   options=[]),
            Select(name="max_sla_days_remaining",
                   title=CasesListPage.Filters.MAX_SLA_DAYS_REMAINING,
                   options=sla_days),
            Select(name="min_sla_days_remaining",
                   title=CasesListPage.Filters.MIN_SLA_DAYS_REMAINING,
                   options=sla_days),
            Select(name="sla_days_elapsed",
                   title=CasesListPage.Filters.SLA_DAYS_ELAPSED,
                   options=sla_days),
            Select(name="sla_days_elapsed_sort_order",
                   title=CasesListPage.Filters.SORT_BY_SLA_ELAPSED,
                   options=sla_sort),
            DateInput(
                name="submitted_from",
                title=CasesListPage.Filters.SUBMITTED_FROM,
                prefix="submitted_from_",
                inline_title=True,
            ),
            DateInput(name="submitted_to",
                      title=CasesListPage.Filters.SUBMITTED_TO,
                      prefix="submitted_to_",
                      inline_title=True),
            DateInput(
                name="finalised_from",
                title=CasesListPage.Filters.FINALISED_FROM,
                prefix="finalised_from_",
                inline_title=True,
            ),
            DateInput(name="finalised_to",
                      title=CasesListPage.Filters.FINALISED_TO,
                      prefix="finalised_to_",
                      inline_title=True),
            TextInput(name="party_name",
                      title=CasesListPage.Filters.PARY_NAME),
            TextInput(name="party_address",
                      title=CasesListPage.Filters.PARTY_ADDRESS),
            TextInput(name="goods_related_description",
                      title=CasesListPage.Filters.GOODS_RELATED_DESCRIPTION),
            AutocompleteInput(
                name="country",
                title=CasesListPage.Filters.COUNTRY,
                options=get_countries(request, convert_to_options=True),
            ),
            AutocompleteInput(
                name="control_list_entry",
                title=CasesListPage.Filters.CONTROL_LIST_ENTRY,
                options=get_control_list_entries(request,
                                                 convert_to_options=True),
            ),
            TokenBar(
                name="flags",
                title=CasesListPage.Filters.FLAGS,
                options=[
                    Option(flag["id"], flag["name"])
                    for flag in get_flags(request, disable_pagination=True)
                ],
            ),
        ],
    )