Example #1
0
    def get(self, request, **kwargs):
        self.organisation_id = str(request.user.organisation)
        self.organisation = get_organisation(request, self.organisation_id)
        user_permissions = kwargs.get("permissions",
                                      get_user_permissions(request))
        can_administer_sites = Permissions.ADMINISTER_SITES in user_permissions
        can_administer_roles = Permissions.EXPORTER_ADMINISTER_ROLES in user_permissions

        context = {
            "organisation":
            self.organisation,
            "can_administer_sites":
            can_administer_sites,
            "can_administer_roles":
            can_administer_roles,
            "user_permissions":
            user_permissions,
            "tabs": [
                Tab("members", Tabs.MEMBERS,
                    reverse_lazy("organisation:members:members")),
                conditional(
                    can_administer_sites,
                    Tab("sites", Tabs.SITES,
                        reverse_lazy("organisation:sites:sites"))),
                conditional(
                    can_administer_roles,
                    Tab("roles", Tabs.ROLES,
                        reverse_lazy("organisation:roles:roles"))),
                Tab("details", Tabs.DETAILS,
                    reverse_lazy("organisation:details")),
            ],
        }
        context.update(self.get_additional_context())
        return render(request, f"organisation/{self.template_name}.html",
                      context)
Example #2
0
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,
    )
Example #3
0
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,
    )
Example #4
0
def approve_licence_form(queue_pk, case_id, is_open_licence, editable_duration, goods, goods_html):
    return Form(
        title=lite_content.lite_internal_frontend.advice.FinaliseLicenceForm.APPROVE_TITLE,
        questions=[
            DateInput(
                description=lite_content.lite_internal_frontend.advice.FinaliseLicenceForm.DATE_DESCRIPTION,
                title=lite_content.lite_internal_frontend.advice.FinaliseLicenceForm.DATE_TITLE,
                prefix="",
            ),
            conditional(
                editable_duration,
                TextInput(
                    title=lite_content.lite_internal_frontend.advice.FinaliseLicenceForm.DURATION_TITLE,
                    name="duration",
                    description=lite_content.lite_internal_frontend.advice.FinaliseLicenceForm.DURATION_DESCRIPTION,
                ),
            ),
            HiddenField(name="action", value="approve"),
            conditional(goods, Custom(goods_html, data=goods,)),
        ],
        container="case",
        back_link=conditional(
            is_open_licence,
            BackLink(
                url=reverse_lazy("cases:finalise_goods_countries", kwargs={"queue_pk": queue_pk, "pk": case_id}),
                text=lite_content.lite_internal_frontend.advice.FinaliseLicenceForm.Actions.BACK_TO_DECISION_MATRIX_BUTTON,
            ),
            BackLink(
                url=reverse_lazy("cases:case", kwargs={"queue_pk": queue_pk, "pk": case_id, "tab": "final-advice"}),
                text=lite_content.lite_internal_frontend.advice.FinaliseLicenceForm.Actions.BACK_TO_ADVICE_BUTTON,
            ),
        ),
    )
Example #5
0
def done_with_case_form(request, queue_pk, case_pk, has_review_date):
    queue = None
    queues, _ = get_user_case_queues(request, case_pk)

    if not queues:
        queue = get_queue(request, queue_pk)

    return Form(
        title=DoneWithCaseOnQueueForm.TITLE if not queue else
        DoneWithCaseOnQueueForm.TITLE_SINGULAR.format(queue["name"]),
        questions=[
            conditional(
                queues,
                Checkboxes(
                    name="queues[]",
                    options=[
                        Option(queue["id"], queue["name"]) for queue in queues
                    ],
                    title=DoneWithCaseOnQueueForm.CHECKBOX_TITLE,
                    description=DoneWithCaseOnQueueForm.CHECKBOX_DESCRIPTION,
                ),
                HiddenField(name="queues[]", value=queue_pk),
            ),
            DetailComponent(
                title=DoneWithCaseOnQueueForm.NOTE,
                components=[
                    TextArea(name="note", classes=["govuk-!-margin-0"]),
                ],
            ),
        ],
        default_button_name=DoneWithCaseOnQueueForm.SUBMIT,
        container="case",
        javascript_imports=conditional(has_review_date,
                                       {"/javascripts/assign_queue.js"}, None),
    )
Example #6
0
def add_goods_questions(request, application_pk=None):
    return Form(
        title=conditional(application_pk, CreateGoodForm.TITLE_APPLICATION, CreateGoodForm.TITLE_GOODS_LIST),
        questions=[
            TextArea(
                title=CreateGoodForm.Description.TITLE,
                description=CreateGoodForm.Description.DESCRIPTION,
                name="description",
                extras={"max_length": 280},
            ),
            TextInput(title=CreateGoodForm.PartNumber.TITLE, name="part_number", optional=True),
            RadioButtons(
                title=CreateGoodForm.IsControlled.TITLE,
                description=conditional(
                    application_pk, CreateGoodForm.IsControlled.DESCRIPTION, CreateGoodForm.IsControlled.CLC_REQUIRED,
                ),
                name="is_good_controlled",
                options=[
                    Option(
                        key="yes",
                        value=CreateGoodForm.IsControlled.YES,
                        components=[
                            control_list_entries_question(
                                control_list_entries=get_control_list_entries(request, convert_to_options=True),
                                title=CreateGoodForm.ControlListEntry.TITLE,
                                description=CreateGoodForm.ControlListEntry.DESCRIPTION,
                            ),
                        ],
                    ),
                    Option(key="no", value=CreateGoodForm.IsControlled.NO),
                    conditional(not application_pk, Option(key="unsure", value=CreateGoodForm.IsControlled.UNSURE)),
                ],
            ),
            RadioButtons(
                title=CreateGoodForm.IsGraded.TITLE,
                description=CreateGoodForm.IsGraded.DESCRIPTION,
                name="is_pv_graded",
                options=[
                    Option(key="yes", value=CreateGoodForm.IsGraded.YES),
                    Option(key="no", value=CreateGoodForm.IsGraded.NO),
                    conditional(
                        not application_pk, Option(key="grading_required", value=CreateGoodForm.IsGraded.RAISE_QUERY)
                    ),
                ],
            ),
        ],
        back_link=conditional(
            application_pk,
            BackLink(generic.BACK, reverse_lazy("applications:goods", kwargs={"pk": application_pk})),
            Breadcrumbs(
                [
                    BackLink(generic.SERVICE_NAME, reverse_lazy("core:home")),
                    BackLink(GoodsList.TITLE, reverse_lazy("goods:goods")),
                    BackLink(GoodsList.CREATE_GOOD),
                ]
            ),
        ),
        default_button_name=CreateGoodForm.SUBMIT_BUTTON,
    )
Example #7
0
def review_goods_form(request, is_goods_type, **kwargs):
    return Form(
        title=cases.ReviewGoodsForm.HEADING,
        questions=[
            RadioButtons(
                title=goods.ReviewGoods.IS_GOOD_CONTROLLED,
                name="is_good_controlled",
                options=[
                    Option(
                        key=conditional(is_goods_type, True, "yes"),
                        value="Yes",
                        components=[
                            control_list_entries_question(
                                control_list_entries=get_control_list_entries(
                                    request, convert_to_options=True),
                                title=goods.ReviewGoods.ControlListEntries.
                                TITLE,
                            ),
                            PicklistPicker(
                                target="report_summary",
                                title=goods.ReviewGoods.ReportSummary.TITLE,
                                description=goods.ReviewGoods.ReportSummary.
                                DESCRIPTION,
                                type=PicklistCategories.report_summary.key,
                                set_text=False,
                            ),
                        ],
                    ),
                    Option(key=conditional(is_goods_type, False, "no"),
                           value="No"),
                ],
            ),
            DetailComponent(
                title=goods.ReviewGoods.Comment.TITLE,
                components=[
                    TextArea(name="comment", extras={
                        "max_length": 500,
                    }),
                ],
            ),
        ],
        default_button_name=cases.ReviewGoodsForm.CONFIRM_BUTTON,
        container="case",
        back_link=BackLink(url=reverse("cases:case",
                                       kwargs={
                                           "queue_pk": kwargs["queue_pk"],
                                           "pk": kwargs["pk"]
                                       })),
        helpers=[
            HelpSection(goods.ReviewGoods.GIVING_ADVICE_ON,
                        "",
                        includes="case/includes/selection-sidebar.html")
        ],
    )
def lite_menu(request):
    has_notifications = False
    try:
        permissions = get_user_permissions(request)
        notifications = get_menu_notifications(request)
        notification_data = notifications["notifications"]
        has_notifications = notifications["has_notifications"]
        pages = [
            {"title": "Cases", "url": reverse_lazy("core:index"), "icon": "menu/cases"},
            {
                "title": OrganisationsPage.TITLE,
                "url": reverse_lazy("organisations:organisations"),
                "icon": "menu/businesses",
                "notifications": notification_data.get("organisations"),
            },
            {"title": TeamsPage.TITLE, "url": reverse_lazy("teams:teams"), "icon": "menu/teams"},
            {"title": "My Team", "url": reverse_lazy("teams:team"), "icon": "menu/teams"},
            {"title": QueuesList.TITLE, "url": reverse_lazy("queues:manage"), "icon": "menu/queues"},
            {"title": UsersPage.TITLE, "url": reverse_lazy("users:users"), "icon": "menu/users"},
            {"title": FlagsList.TITLE, "url": reverse_lazy("flags:flags"), "icon": "menu/flags"},
            conditional(
                Permission.MAINTAIN_OGL.value in permissions,
                {
                    "title": open_general_licences.List.TITLE,
                    "url": reverse_lazy("open_general_licences:open_general_licences"),
                    "icon": "menu/open-general-licences",
                },
            ),
            conditional(
                Permission.CONFIGURE_TEMPLATES.value in permissions,
                {
                    "title": strings.DOCUMENT_TEMPLATES_TITLE,
                    "url": reverse_lazy("letter_templates:letter_templates"),
                    "icon": "menu/letter-templates",
                },
            ),
            conditional(
                Permission.MANAGE_FLAGGING_RULES.value in permissions,
                {"title": "Flagging rules", "url": reverse_lazy("flags:flagging_rules"), "icon": "menu/flags"},
            ),
            conditional(
                Permission.MANAGE_TEAM_ROUTING_RULES.value in permissions
                or Permission.MANAGE_ALL_ROUTING_RULES.value in permissions,
                {"title": "Routing rules", "url": reverse_lazy("routing_rules:list"), "icon": "menu/routing-rules"},
            ),
        ]
    except AttributeError:
        # Tests dont provide a user which causes has_permission to error,
        # so return an empty pages list so tests work
        pages = []
    return {"LITE_MENU": [x for x in pages if x is not None], "MENU_NOTIFICATIONS": has_notifications}
Example #9
0
def which_location_form(application_id, application_type):
    return Form(
        title=goods.GoodsLocationForm.WHERE_ARE_YOUR_GOODS_LOCATED_TITLE,
        description=goods.GoodsLocationForm.WHERE_ARE_YOUR_GOODS_LOCATED_DESCRIPTION,
        questions=[
            RadioButtons(
                "choice",
                [
                    Option(
                        key=Locations.ORGANISATION,
                        value=goods.GoodsLocationForm.ONE_OF_MY_REGISTERED_SITES,
                        description=goods.GoodsLocationForm.NOT_AT_MY_REGISTERED_SITES_DESCRIPTION,
                    ),
                    Option(
                        key=Locations.EXTERNAL,
                        value=goods.GoodsLocationForm.NOT_AT_MY_REGISTERED_SITES,
                        description=goods.GoodsLocationForm.NOT_AT_MY_REGISTERED_SITES_DESCRIPTION,
                    ),
                    conditional(
                        application_type == HMRC,
                        Option(
                            key=Locations.DEPARTED,
                            value=goods.GoodsLocationForm.DEPARTED_THE_COUNTRY,
                            description=goods.GoodsLocationForm.DEPARTED_THE_COUNTRY_DESCRIPTION,
                            show_or=True,
                        ),
                    ),
                ],
            )
        ],
        default_button_name=strings.CONTINUE,
        back_link=back_to_task_list(application_id),
    )
Example #10
0
def _convert_hmrc_query(application, editable=False):
    return {
        applications.ApplicationSummaryPage.ON_BEHALF_OF:
        application["organisation"]["name"],
        applications.ApplicationSummaryPage.GOODS:
        _convert_goods_types(application["goods_types"]),
        applications.ApplicationSummaryPage.GOODS_LOCATIONS:
        conditional(
            application["have_goods_departed"],
            {applications.ApplicationSummaryPage.GOODS_DEPARTED: "Yes"},
            _convert_goods_locations(application["goods_locations"]),
        ),
        applications.ApplicationSummaryPage.END_USER:
        convert_party(application["end_user"], application, editable),
        applications.ApplicationSummaryPage.ULTIMATE_END_USERS: [
            convert_party(party, application, editable)
            for party in application["ultimate_end_users"]
        ],
        applications.ApplicationSummaryPage.THIRD_PARTIES: [
            convert_party(party, application, editable)
            for party in application["third_parties"]
        ],
        applications.ApplicationSummaryPage.CONSIGNEE:
        convert_party(application["consignee"], application, editable),
        applications.ApplicationSummaryPage.SUPPORTING_DOCUMENTATION:
        _get_supporting_documentation(application["supporting_documentation"],
                                      application["id"]),
        applications.ApplicationSummaryPage.OPTIONAL_NOTE:
        application["reasoning"],
    }
Example #11
0
def edit_individual_form(organisation, can_edit_name, are_fields_optional):
    return Form(
        title=EditIndividualOrganisationPage.TITLE,
        questions=[
            conditional(
                can_edit_name,
                TextInput(
                    title=EditIndividualOrganisationPage.Name.TITLE,
                    description=EditIndividualOrganisationPage.Name.
                    DESCRIPTION,
                    name="name",
                ),
            ),
            TextInput(
                title=EditIndividualOrganisationPage.EORINumber.TITLE,
                description=EditIndividualOrganisationPage.Name.DESCRIPTION,
                name="eori_number",
                optional=are_fields_optional,
            ),
            TextInput(
                title=EditIndividualOrganisationPage.VATNumber.TITLE,
                description=EditIndividualOrganisationPage.VATNumber.
                DESCRIPTION,
                optional=True,
                name="vat_number",
            ),
        ],
        back_link=BackLink(
            EditIndividualOrganisationPage.BACK_LINK,
            reverse("organisations:organisation",
                    kwargs={"pk": organisation["id"]}),
        ),
        default_button_name=EditIndividualOrganisationPage.SUBMIT_BUTTON,
    )
Example #12
0
def edit_user_form(request, user, can_edit_role: bool):
    return Form(
        title=EditUserForm.TITLE.format(user["first_name"], user["last_name"]),
        questions=[
            TextInput(title=EditUserForm.Email.TITLE, description=EditUserForm.Email.DESCRIPTION, name="email"),
            Select(
                title=EditUserForm.Team.TITLE,
                description=EditUserForm.Team.DESCRIPTION,
                name="team",
                options=get_teams(request, True),
            ),
            conditional(
                can_edit_role,
                Select(
                    title=EditUserForm.Role.TITLE,
                    description=EditUserForm.Role.DESCRIPTION,
                    name="role",
                    options=get_roles(request, True),
                ),
            ),
            Select(
                title=EditUserForm.DefaultQueue.TITLE,
                description=EditUserForm.DefaultQueue.DESCRIPTION,
                name="default_queue",
                options=get_queues(request, include_system=True, convert_to_options=True),
            ),
        ],
        back_link=BackLink(
            EditUserForm.BACK_LINK.format(user["first_name"], user["last_name"]),
            reverse_lazy("users:user", kwargs={"pk": user["id"]}),
        ),
        default_button_name=EditUserForm.SUBMIT_BUTTON,
        javascript_imports={"/javascripts/filter-default-queue-list.js"},
    )
Example #13
0
    def get(self, request, *args, **kwargs):
        organisation = get_user(request, params={"in_review":
                                                 True})["organisations"][0]
        organisation_name = organisation["name"]
        organisation_status = organisation["status"]["key"]

        if organisation_status != "in_review":
            raise Http404

        return success_page(
            request=request,
            title=f"You've successfully registered: {organisation_name}",
            secondary_title="We're currently processing your application.",
            description="",
            what_happens_next=[
                "Export Control Joint Unit (ECJU) is processing your request for an export control account. "
                "We'll send you an email when we've made a final decision."
            ],
            links={},
            back_link=conditional(
                request.GET.get("show_back_link", False),
                BackLink(generic.BACK,
                         reverse_lazy("core:pick_organisation"))),
            animated=True,
            additional_context={"user_in_limbo": True},
        )
Example #14
0
def told_by_an_official_form(application_id=None):
    return Form(
        title=ExportLicenceQuestions.HaveYouBeenInformedQuestion.TITLE,
        description=ExportLicenceQuestions.HaveYouBeenInformedQuestion.
        DESCRIPTION,
        questions=[
            RadioButtons(
                name="have_you_been_informed",
                options=[
                    Option(
                        key="yes",
                        value=strings.YES,
                        components=[
                            TextInput(
                                title=ExportLicenceQuestions.
                                HaveYouBeenInformedQuestion.
                                WHAT_WAS_THE_REFERENCE_CODE_TITLE,
                                description=ExportLicenceQuestions.
                                HaveYouBeenInformedQuestion.
                                WHAT_WAS_THE_REFERENCE_CODE_DESCRIPTION,
                                name="reference_number_on_information_form",
                                optional=True,
                            ),
                        ],
                    ),
                    Option(key="no", value=strings.NO),
                ],
            ),
        ],
        back_link=back_to_task_list(application_id),
        default_button_name=conditional(application_id,
                                        generic.SAVE_AND_RETURN,
                                        generic.CONTINUE),
    )
Example #15
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 #16
0
def foreign_address_questions(countries, prefix="address."):
    return [
        TextArea(title="Address",
                 name=prefix + "address",
                 classes=["govuk-input--width-20"],
                 rows=6),
        conditional(countries, country_question(countries, prefix)),
    ]
Example #17
0
    def get(self, request, **kwargs):
        params = {
            "page":
            int(request.GET.get("page", 1)),
            **get_params_if_exist(request, [
                "case_status", "team", "queue", "tier", "only_active"
            ]),
        }
        data, _ = get_routing_rules(request,
                                    convert_dict_to_query_params(params))

        user_data, _ = get_gov_user(request,
                                    str(request.session["lite_api_user_id"]))

        status = request.GET.get("status", "active")

        filters = FiltersBar([
            Select(title=Filter.CASE_STATUS,
                   name="case_status",
                   options=get_statuses(request, True)),
            *conditional(
                has_permission(request, Permission.MANAGE_ALL_ROUTING_RULES),
                [
                    Select(title=Filter.TEAM,
                           name="team",
                           options=get_teams(request, True)),
                    AutocompleteInput(
                        title=Filter.QUEUE,
                        name="queue",
                        options=get_queues(request, convert_to_options=True),
                    ),
                ],
                [
                    AutocompleteInput(
                        title=Filter.QUEUE,
                        name="queue",
                        options=get_users_team_queues(
                            request, request.session["lite_api_user_id"],
                            True),
                    ),
                ],
            ),
            TextInput(title=Filter.TIER, name="tier"),
            Checkboxes(
                name="only_active",
                options=[Option(True, Filter.ACTIVE_ONLY)],
                classes=["govuk-checkboxes--small"],
            ),
        ])

        context = {
            "data": data,
            "status": status,
            "user_data": user_data,
            "filters": filters,
        }
        return render(request, "routing-rules/index.html", context)
Example #18
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 #19
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)),
    ])
Example #20
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 #21
0
def edit_address_questions_form(is_commercial,
                                in_uk,
                                countries,
                                prefix="site.address."):
    phone_number_label = "Organisation phone number" if is_commercial else "Phone number"

    if in_uk:
        questions = [
            TextInput(title=RegisterAnOrganisation.NAME_OF_SITE,
                      name="site.name"),
            Heading(RegisterAnOrganisation.WhereIsTheExporterBased.TITLE,
                    HeadingStyle.M),
            TextInput(
                title="Building and street",
                accessible_description="line 1 of 2",
                name=prefix + "address_line_1",
            ),
            TextInput(
                title="",
                accessible_description="line 2 of 2",
                name=prefix + "address_line_2",
            ),
            TextInput(title="Town or city", name=prefix + "city"),
            TextInput(title="County or state", name=prefix + "region"),
            TextInput(title="Postcode", name=prefix + "postcode"),
        ]
    else:
        questions = [
            TextInput(title=RegisterAnOrganisation.NAME_OF_SITE,
                      name="site.name"),
            Heading(RegisterAnOrganisation.WhereIsTheExporterBased.TITLE,
                    HeadingStyle.M),
            TextArea(title="Address",
                     name=prefix + "address",
                     classes=["govuk-input--width-20"],
                     rows=6),
        ]

    return Form(
        title="Edit default site for this exporter",
        questions=questions + [
            TextInput(
                title=phone_number_label,
                name="phone_number",
                description=
                "For international numbers include the country code",
            ),
            TextInput(title="Website", name="website", optional=True),
            conditional(
                not in_uk,
                AutocompleteInput(title="Country",
                                  name=prefix + "country",
                                  options=countries)),
        ],
    )
Example #22
0
    def get(self, request, **kwargs):
        self.organisation_id = str(request.session["organisation"])
        self.organisation = get_organisation(request, self.organisation_id)

        user_permissions = kwargs.get("permissions",
                                      get_user_permissions(request))
        can_administer_sites = Permissions.ADMINISTER_SITES in user_permissions
        can_administer_roles = Permissions.EXPORTER_ADMINISTER_ROLES in user_permissions

        documents = {
            item["document_type"].replace("-", "_"): item
            for item in self.organisation.get("documents", [])
        }
        context = {
            "organisation":
            self.organisation,
            "can_administer_sites":
            can_administer_sites,
            "can_administer_roles":
            can_administer_roles,
            "user_permissions":
            user_permissions,
            "tabs": [
                Tab("members", Tabs.MEMBERS,
                    reverse_lazy("organisation:members:members")),
                conditional(
                    can_administer_sites,
                    Tab("sites", Tabs.SITES,
                        reverse_lazy("organisation:sites:sites"))),
                conditional(
                    can_administer_roles,
                    Tab("roles", Tabs.ROLES,
                        reverse_lazy("organisation:roles:roles"))),
                Tab("details", Tabs.DETAILS,
                    reverse_lazy("organisation:details")),
            ],
            "documents":
            documents,
            **self.get_additional_context(),
        }
        return render(request, f"organisation/{self.template_name}.html",
                      context)
Example #23
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(),
        ]
    )
Example #24
0
def assign_case_officer_form(request: HttpRequest,
                             existing_officer,
                             queue_id,
                             case_id,
                             is_compliance=None):
    params = {"disable_pagination": True, "status": UserStatuses.ACTIVE}
    users = get_gov_users(request, params, convert_to_options=True)
    buttons = [
        Button(cases.Manage.AssignCaseOfficer.SUBMIT_BUTTON, action="submit")
    ]
    if existing_officer:
        buttons.append(
            Button(
                conditional(
                    is_compliance,
                    cases.Manage.AssignCaseOfficer.DELETE_INSPECTOR_BUTTON,
                    cases.Manage.AssignCaseOfficer.DELETE_BUTTON,
                ),
                action="delete",
                id="unassign",
                style=ButtonStyle.WARNING,
            ))

    return Form(
        title=conditional(is_compliance,
                          cases.Manage.AssignCaseOfficer.INSPECTOR_TITLE,
                          cases.Manage.AssignCaseOfficer.TITLE),
        description=cases.Manage.AssignCaseOfficer.DESCRIPTION,
        questions=[
            Filter(),
            RadioButtons("gov_user_pk", users, filterable=True)
        ],
        buttons=buttons,
        container="case",
        back_link=BackLink(url=reverse("cases:case",
                                       kwargs={
                                           "queue_pk": queue_id,
                                           "pk": case_id,
                                           "tab": "details"
                                       })),
    )
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)
            ],
            [],
        ),
    ])
Example #26
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 #27
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(),
    ])
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 #29
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,
    )
Example #30
0
def reference_name_form(application_id=None):
    return Form(
        title=applications.InitialApplicationQuestionsForms.
        ReferenceNameQuestion.TITLE,
        description=applications.InitialApplicationQuestionsForms.
        ReferenceNameQuestion.DESCRIPTION,
        questions=[
            TextInput(name="name"),
        ],
        back_link=back_to_task_list(application_id),
        default_button_name=conditional(application_id,
                                        generic.SAVE_AND_RETURN,
                                        generic.CONTINUE),
    )