Beispiel #1
0
    def get(self, request, **kwargs):
        data = get_teams(request)

        context = {
            "data": data,
        }
        return render(request, "teams/index.html", context)
Beispiel #2
0
def add_user_form(request):
    return Form(
        title=AddUserForm.TITLE,
        questions=[
            TextInput(title=AddUserForm.Email.TITLE,
                      description=AddUserForm.Email.DESCRIPTION,
                      name="email"),
            Select(
                title=AddUserForm.Team.TITLE,
                description=AddUserForm.Team.DESCRIPTION,
                name="team",
                options=get_teams(request, True),
            ),
            Select(
                title=AddUserForm.Role.TITLE,
                description=AddUserForm.Role.DESCRIPTION,
                name="role",
                options=get_roles(request, True),
            ),
            Select(
                title=AddUserForm.DefaultQueue.TITLE,
                description=AddUserForm.DefaultQueue.DESCRIPTION,
                name="default_queue",
                options=get_queues(request,
                                   include_system=True,
                                   convert_to_options=True),
            ),
        ],
        back_link=BackLink(AddUserForm.BACK_LINK, reverse_lazy("users:users")),
        javascript_imports={"/javascripts/filter-default-queue-list.js"},
    )
Beispiel #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.session["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)
Beispiel #4
0
def select_a_team(request):
    return Form(
        title=Forms.TEAM,
        questions=[
            RadioButtons(name="team", options=get_teams(request, True)),
        ],
        back_link=BackLink(Forms.BACK_BUTTON,
                           reverse_lazy("routing_rules:list")),
    )
Beispiel #5
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)
Beispiel #6
0
def initial_routing_rule_questions(request, select_team, team_id,
                                   is_editing: bool):

    team_queues_options = get_team_queues(request,
                                          team_id,
                                          convert_to_options=True,
                                          ignore_pagination=True)

    return Form(
        title=Forms.EDIT_TITLE if is_editing else Forms.CREATE_TITLE,
        questions=[
            AutocompleteInput(
                title=Forms.TEAM,
                name="team",
                options=get_teams(request, True),
                description="Type to get suggestions. For example, TAU.",
            ),
            Select(title=Forms.CASE_STATUS,
                   name="status",
                   options=get_statuses(request, True)),
            AutocompleteInput(
                title=Forms.QUEUE,
                name="queue",
                options=team_queues_options,
                description=
                "Type to get suggestions.\nFor example, HMRC enquiries.",
            ),
            TextInput(title=Forms.TIER, name="tier"),
            HiddenField(name="additional_rules[]", value=None),
            Checkboxes(
                title=Forms.ADDITIONAL_RULES,
                name="additional_rules[]",
                options=additional_rules,
            ),
        ],
        back_link=BackLink(Forms.BACK_BUTTON,
                           reverse_lazy("routing_rules:list")),
        javascript_imports={"/javascripts/routing-rules-teams.js"},
    )
Beispiel #7
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"},
    )
Beispiel #8
0
def initial_routing_rule_questions(request, select_team, team_id,
                                   is_editing: bool):
    select_team_question = []
    if select_team:
        select_team_question = [
            AutocompleteInput(
                title=Forms.TEAM,
                name="team",
                options=get_teams(request, True),
                description="Type to get suggestions. For example, TAU.",
            ),
        ]

    return Form(
        title=Forms.EDIT_TITLE if is_editing else Forms.CREATE_TITLE,
        questions=select_team_question + [
            Select(title=Forms.CASE_STATUS,
                   name="status",
                   options=get_statuses(request, True)),
            AutocompleteInput(
                title=Forms.QUEUE,
                name="queue",
                options=get_team_queues(request, team_id, True, True)
                if team_id else [],
                description=
                "Type to get suggestions.\nFor example, HMRC enquiries.",
            ),
            TextInput(title=Forms.TIER, name="tier"),
            HiddenField(name="additional_rules[]", value=None),
            Checkboxes(
                title=Forms.ADDITIONAL_RULES,
                name="additional_rules[]",
                options=additional_rules,
            ),
        ],
        back_link=BackLink(Forms.BACK_BUTTON,
                           reverse_lazy("routing_rules:list")),
    )
Beispiel #9
0
    if filter_advice_by_level(
            case["advice"],
            "final") and _check_user_permitted_to_give_final_advice(
                case.data["case_type"]["sub_type"]["key"], permissions):
        current_advice_level = "final"

    if not _can_user_create_and_edit_advice(
            case, permissions) or status_props["is_terminal"]:
        current_advice_level = None

    return {
        "is_user_team":
        True,
        "teams":
        get_teams(request),
        "current_advice_level":
        current_advice_level,
        "can_finalise":
        current_advice_level == "final" and can_advice_be_finalised(case)
        and not blocking_flags,
        "blocking_flags":
        blocking_flags,
    }


def same_value(dicts, key):
    original_value = dicts[0][key]

    for dict in dicts:
        if dict[key] != original_value:
Beispiel #10
0
        advice_types = set([f["type"]["key"] for f in other_advice])

        if advice_types == {"approve", "proviso"}:
            conflicting_other_advice = False
        else:
            conflicting_other_advice = len(advice_types) > 1

        conflicting_advice = conflicting_goods_advice or conflicting_other_advice

        if blocking_flags:
            logger.debug("Cannot finalise because of blocking_flags: %s",
                         blocking_flags)
            return {
                "conflicting_advice": conflicting_advice,
                "teams": get_teams(self.request),
                "current_advice_level": current_advice_level,
                "can_finalise": False,
                "blocking_flags": blocking_flags,
            }

        refuse_all = set([f["type"]["key"]
                          for f in final_advice]) == {"refuse"}

        can_finalise = ("final" in current_advice_level
                        and advice_helpers.can_advice_be_finalised(self.case)
                        and not conflicting_advice
                        and goods_list_has_at_least_one_approval) or refuse_all

        return {
            "conflicting_advice": conflicting_advice,