Exemplo n.º 1
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)
Exemplo n.º 2
0
def generate_activity_filters(activity_filters, string_class):
    def make_options(values):
        return [Option(option["key"], option["value"]) for option in values]

    return FiltersBar(
        [
            Select(
                title=string_class.ActivityFilters.USER,
                name="user_id",
                options=make_options(activity_filters["users"]),
            ),
            Select(
                title=string_class.ActivityFilters.TEAM,
                name="team_id",
                options=make_options(activity_filters["teams"]),
            ),
            Select(
                title=string_class.ActivityFilters.USER_TYPE,
                name="user_type",
                options=make_options(activity_filters["user_types"]),
            ),
            Select(
                title=string_class.ActivityFilters.ACTIVITY_TYPE,
                name="activity_type",
                options=make_options(activity_filters["activity_types"]),
            ),
            DateInput(title=string_class.ActivityFilters.DATE_FROM, prefix="from_", inline_title=True),
            DateInput(title=string_class.ActivityFilters.DATE_TO, prefix="to_", inline_title=True),
        ]
    )
Exemplo n.º 3
0
    def get(self, request, **kwargs):
        params = request.GET.copy()
        params["status"] = params.get("status", FlagStatus.ACTIVE.value)
        data = get_flags(request, **params)
        user_data, _ = get_gov_user(request, str(request.user.lite_api_user_id))

        filters = FiltersBar(
            [
                TextInput(name="name", title="name"),
                Select(name="level", title="level", options=level_options),
                TextInput(name="priority", title="priority"),
                Select(name="team", title="team", options=get_teams(request, True)),
                Checkboxes(
                    name="status",
                    options=[Option(FlagStatus.DEACTIVATED.value, flags.FlagsList.SHOW_DEACTIVATED_FLAGS)],
                    classes=["govuk-checkboxes--small"],
                ),
            ]
        )

        context = {
            "data": data,
            "user_data": user_data,
            "filters": filters,
            "can_change_flag_status": Permission.ACTIVATE_FLAGS.value in get_user_permissions(request),
        }
        return render(request, "flags/index.html", context)
Exemplo n.º 4
0
    def get(self, request, **kwargs):
        """
        List of existing parties
        """
        application_id = str(kwargs["pk"])
        parties, _ = get_existing_parties(
            request,
            application_id,
            name=request.GET.get("name"),
            address=request.GET.get("address"),
            country=request.GET.get("country"),
            page=request.GET.get("page"),
            party_type=self.new_party_type,
        )

        filters = FiltersBar([
            TextInput(title="name", name="name"),
            TextInput(title="address", name="address"),
            TextInput(title="country", name="country"),
        ])

        context = {
            "title": CopyExistingPartyPage.TITLE,
            "back_url": self.back_url,
            "filters": filters,
            "draft_id": application_id,
            "data": parties,
            "url": self.copy_url,
            "new_party_type": self.new_party_type,
        }
        return render(request, "applications/parties/preexisting.html",
                      context)
Exemplo n.º 5
0
    def get_additional_context(self):
        status = self.request.GET.get("status")
        params = {"page": int(self.request.GET.get("page", 1))}
        if status:
            params["status"] = status
        users = get_organisation_users(
            self.request, str(self.request.session["organisation"]), params)
        statuses = [
            Option(option["key"], option["value"]) for option in [
                {
                    "key": "active",
                    "value": "Active"
                },
                {
                    "key": "deactivated",
                    "value": "Deactivated"
                },
                {
                    "key": "",
                    "value": "All"
                },
            ]
        ]
        filters = FiltersBar(
            [Select(name="status", title="status", options=statuses)])

        return {
            "status": status,
            "data": users,
            "page": params.pop("page"),
            "params_str": convert_dict_to_query_params(params),
            "filters": filters,
        }
Exemplo n.º 6
0
    def get(self, request, **kwargs):
        if Permission.MANAGE_FLAGGING_RULES.value not in get_user_permissions(request):
            return redirect(reverse_lazy("cases:cases"))

        params = {"page": int(request.GET.get("page", 1))}
        params = get_params_if_exist(request, ["only_my_team", "level", "include_deactivated"], params)

        data, _ = get_flagging_rules(request, convert_dict_to_query_params(params))

        filters = FiltersBar(
            [
                Select(name="level", title=strings.FlaggingRules.List.Filter.Type, options=_levels),
                Checkboxes(
                    name="only_my_team",
                    options=[Option("true", strings.FlaggingRules.List.Filter.MY_TEAM_ONLY)],
                    classes=["govuk-checkboxes--small", "govuk-!-margin-top-6"],
                ),
                Checkboxes(
                    name="include_deactivated",
                    options=[Option("true", strings.FlaggingRules.List.Filter.INCLUDE_DEACTIVATED)],
                    classes=["govuk-checkboxes--small", "govuk-!-margin-top-6"],
                ),
            ]
        )

        context = {
            "data": data,
            "team": get_gov_user(request)[0]["user"]["team"]["id"],
            "filters": filters,
        }
        return render(request, "flags/flagging-rules-list.html", context)
Exemplo n.º 7
0
    def get(self, request, **kwargs):
        description = request.GET.get("description", "").strip()
        part_number = request.GET.get("part_number", "").strip()
        control_list_entry = request.GET.get("control_list_entry", "").strip()

        filters = FiltersBar([
            TextInput(title="description", name="description"),
            TextInput(title="control list entry", name="control_list_entry"),
            TextInput(title="part number", name="part_number"),
        ])

        params = {
            "page": int(request.GET.get("page", 1)),
            "description": description,
            "part_number": part_number,
            "control_list_entry": control_list_entry,
        }

        context = {
            "goods": get_goods(request, **params),
            "description": description,
            "part_number": part_number,
            "control_list_entry": control_list_entry,
            "filters": filters,
        }
        return render(request, "goods/goods.html", context)
Exemplo n.º 8
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)
Exemplo n.º 9
0
    def get(self, request, **kwargs):
        """
        List of existing goods (add-preexisting)
        """
        application_id = str(kwargs["pk"])
        application = get_application(request, application_id)
        name = request.GET.get("name", "").strip()
        description = request.GET.get("description", "").strip()
        part_number = request.GET.get("part_number", "").strip()
        control_list_entry = request.GET.get("control_list_entry", "").strip()

        filters = FiltersBar([
            TextInput(title="name", name="name"),
            TextInput(title="description", name="description"),
            TextInput(title="control list entry", name="control_list_entry"),
            TextInput(title="part number", name="part_number"),
        ])

        params = {
            "page": int(request.GET.get("page", 1)),
            "name": name,
            "description": description,
            "part_number": part_number,
            "control_list_entry": control_list_entry,
            "for_application": "True",
        }
        goods_list = get_goods(request, **params)

        context = {
            "application":
            application,
            "data":
            goods_list,
            "name":
            name,
            "description":
            description,
            "part_number":
            part_number,
            "control_list_entry":
            control_list_entry,
            "draft_id":
            application_id,
            "params":
            params,
            "page":
            params.pop("page"),
            "params_str":
            convert_dict_to_query_params(params),
            "filters":
            filters,
            "feature_flag_firearms_enabled":
            settings.FEATURE_FLAG_FIREARMS_ENABLED,
        }
        return render(request, "applications/goods/preexisting.html", context)
Exemplo n.º 10
0
 def get_compliance_site(self):
     self.tabs = self.get_tabs()
     self.tabs.insert(1, Tabs.COMPLIANCE_LICENCES)
     self.slices = [Slices.COMPLIANCE_VISITS, Slices.OPEN_LICENCE_RETURNS]
     filters = FiltersBar([TextInput(name="reference", title=cases.CasePage.LicenceFilters.REFERENCE),])
     self.additional_context = {
         "data": get_compliance_licences(
             self.request, self.case.id, self.request.GET.get("reference", ""), self.request.GET.get("page", 1),
         ),
         "licences_filters": filters,
     }
Exemplo n.º 11
0
    def get(self, request, **kwargs):
        params = convert_parameters_to_query_params(
            {"page": request.GET.get("page", 1), "name": request.GET.get("name")}
        )
        end_users = get_end_user_advisories(request, params)

        filters = FiltersBar([TextInput(title="name", name="name"),])

        context = {
            "filters": filters,
            "end_users": end_users,
        }
        return render(request, "end-users/end-users.html", context)
Exemplo n.º 12
0
    def get(self, request, **kwargs):
        search_term = request.GET.get("search_term", "").strip()
        org_type = request.GET.get("org_type", "").strip()

        params = {
            "page": int(request.GET.get("page", 1)),
            "status": request.GET.get("status", "active")
        }
        if search_term:
            params["search_term"] = search_term
        if org_type:
            params["org_type"] = org_type

        organisations, _ = get_organisations(
            request, convert_dict_to_query_params(params))

        filters = FiltersBar([
            TextInput(name="search_term",
                      title=OrganisationsPage.Filters.NAME),
            Select(
                name="org_type",
                title=OrganisationsPage.Filters.TYPE,
                options=[
                    Option("individual",
                           OrganisationsPage.Filters.Types.INDIVIDUAL),
                    Option("commercial",
                           OrganisationsPage.Filters.Types.COMMERCIAL),
                    Option("hmrc", OrganisationsPage.Filters.Types.HMRC),
                ],
            ),
            HiddenField(name="status", value=params["status"]),
        ])

        context = {
            "data":
            organisations,
            "filters":
            filters,
            "search_term":
            params.get("search_term", ""),
            "tab":
            params.get("status"),
            "in_review_total":
            get_menu_notifications(request)["notifications"].get(
                "organisations"),
            "can_manage_organisations":
            Permission.MANAGE_ORGANISATIONS.value
            in get_user_permissions(request),
        }
        return render(request, "organisations/index.html", context)
Exemplo n.º 13
0
    def get(self, request, **kwargs):
        page = request.GET.get("page", 1)
        name = request.GET.get("name")
        queues = get_queues(request, page=page, disable_pagination=False, name=name)
        user_data, _ = get_gov_user(request, str(request.user.lite_api_user_id))

        filters = FiltersBar([TextInput(name="name", title="name"),])

        context = {
            "data": queues,
            "user_data": user_data,
            "filters": filters,
            "name": name,
        }
        return render(request, "queues/manage.html", context)
Exemplo n.º 14
0
    def get(self, request, **kwargs):
        params = {
            "page": int(request.GET.get("page", 1)),
            "name": request.GET.get("name", "")
        }

        data, _ = get_letter_templates(request,
                                       convert_dict_to_query_params(params))
        filters = FiltersBar([
            TextInput(name="name", title="name"),
        ])
        context = {
            "data": data,
            "filters": filters,
        }
        return render(request, "letter-templates/letter-templates.html",
                      context)
Exemplo n.º 15
0
    def get(self, request, **kwargs):
        self.type = request.GET.get("licence_type", "licences")
        self.page = int(request.GET.get("page", 1))
        getattr(self, f"get_{self.type}", self.get_licences)()  # Set template properties

        context = {
            "data": self.data,
            "filters": FiltersBar([*self.filters, HiddenField(name="licence_type", value=self.type)]),
            "tabs": [
                Tab("licences", LicencesList.Tabs.LICENCE, "?licence_type=licences"),
                Tab("open_general_licences", LicencesList.Tabs.OGLS, "?licence_type=open_general_licences"),
                Tab("no_licence_required", LicencesList.Tabs.NLR, "?licence_type=no_licence_required"),
                Tab("clearances", LicencesList.Tabs.CLEARANCE, "?licence_type=clearances"),
            ],
            "selected_tab": self.type,
            "reference": request.GET.get("reference", ""),
            "name": request.GET.get("name", ""),
            "row_limit": 3,
        }
        return render(request, f"licences/{self.template}.html", context)
Exemplo n.º 16
0
    def get(self, request, **kwargs):
        params = {
            "page": int(self.request.GET.get("page", 1)),
            "email": self.request.GET.get("email", ""),
            "status": self.request.GET.get("status", ""),
        }

        data, _ = get_gov_users(request, params)

        user, _ = get_gov_user(request,
                               str(request.session["lite_api_user_id"]))
        super_user = is_super_user(user)

        statuses = [
            Option(option["key"], option["value"]) for option in [
                {
                    "key": "active",
                    "value": UserStatuses.ACTIVE
                },
                {
                    "key": "deactivated",
                    "value": UserStatuses.DEACTIVATED
                },
                {
                    "key": "",
                    "value": "All"
                },
            ]
        ]

        filters = FiltersBar([
            Select(name="status", title="status", options=statuses),
            TextInput(name="email", title="email"),
        ])

        context = {
            "data": data,
            "super_user": super_user,
            "filters": filters,
        }
        return render(request, "users/index.html", context)
Exemplo n.º 17
0
    def get(self, request, **kwargs):
        """
        Return a list of picklists and show all the relevant items
        """
        picklist_type = request.GET.get(
            "type",
            PicklistCategories.proviso.key)  # Ensure that the page has a type
        user, _ = get_gov_user(request)
        team, _ = get_team(request, user["user"]["team"]["id"])
        picklist_items = get_picklists_list(request,
                                            type=picklist_type,
                                            page=request.GET.get("page", 1),
                                            name=request.GET.get("name"))

        active_picklist_items = [
            x for x in picklist_items["results"]
            if x["status"]["key"] == "active"
        ]
        deactivated_picklist_items = [
            x for x in picklist_items["results"]
            if x["status"]["key"] != "active"
        ]

        filters = FiltersBar([
            HiddenField(name="type", value=picklist_type),
            TextInput(name="name", title="name")
        ])

        context = {
            "team": team["team"],
            "active_picklist_items": active_picklist_items,
            "deactivated_picklist_items": deactivated_picklist_items,
            "data": picklist_items,
            "type": picklist_type,
            "filters": filters,
            "name": request.GET.get("name"),
            "picklist_categories": PicklistCategories.all(),
        }
        return render(request, "teams/picklists.html", context)
Exemplo n.º 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)
                ],
            ),
        ],
    )