Skip to content

Commit

Permalink
Merge pull request #2265 from uktrade/LTD-5712-queue-view-exclude-flags
Browse files Browse the repository at this point in the history
[LTD-5712] Add ability to exclude cases with certain flags from queue view
  • Loading branch information
currycoder authored Dec 12, 2024
2 parents d69a84f + 1d71b36 commit ff1a080
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions caseworker/queues/views/cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ def get_params(self):
params[param] = date_obj

params["flags"] = self.request.GET.getlist("flags", [])
params["exclude_flags"] = self.request.GET.getlist("exclude_flags", [])
params["countries"] = self.request.GET.getlist("countries", [])
params["assigned_queues"] = self.request.GET.getlist("assigned_queues", [])
params["control_list_entry"] = self.request.GET.getlist("control_list_entry", [])
Expand Down
9 changes: 9 additions & 0 deletions caseworker/queues/views/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,14 @@ def __init__(self, queue, filters_data, all_flags, all_cles, all_regimes, countr
# setting id for javascript to use
widget=forms.SelectMultiple(attrs={"id": "flags"}),
)
self.fields["exclude_flags"] = forms.MultipleChoiceField(
label="Exclude flags",
choices=flags_choices,
required=False,
help_text=f'<a href="{flag_url}" class="govuk-link govuk-link--no-visited-state" target="_blank">Flag information (open in a new window)</a>',
# setting id for javascript to use
widget=forms.SelectMultiple(attrs={"id": "exclude_flags"}),
)
self.fields["control_list_entry"] = forms.MultipleChoiceField(
label="Control list entry",
choices=cle_choices,
Expand Down Expand Up @@ -220,6 +228,7 @@ def __init__(self, queue, filters_data, all_flags, all_cles, all_regimes, countr
"submitted_from",
"submitted_to",
Field("flags", css_class="multi-select-filter"),
Field("exclude_flags", css_class="multi-select-filter"),
"finalised_from",
"finalised_to",
]
Expand Down
14 changes: 14 additions & 0 deletions unit_tests/caseworker/queues/views/test_cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ def test_cases_home_page_view_context(authorized_client):
"assigned_user",
"licence_status",
"flags",
"exclude_flags",
"countries",
"assigned_queues",
"is_nca_applicable",
Expand Down Expand Up @@ -371,6 +372,19 @@ def test_cases_home_page_exclude_control_list_entries_search(authorized_client,
}


def test_cases_home_page_exclude_flags_search(authorized_client, mock_cases_search):
url = reverse("queues:cases")
response = authorized_client.get(url)

url = reverse("queues:cases") + "?exclude_flags=flag_id_1&exclude_flags=flag_id_2"
response = authorized_client.get(url)
assert response.status_code == 200
assert mock_cases_search.last_request.qs == {
**default_params,
"exclude_flags": ["flag_id_1", "flag_id_2"],
}


def test_cases_home_page_max_total_value_search(authorized_client, mock_cases_search):
url = reverse("queues:cases")
response = authorized_client.get(url)
Expand Down

0 comments on commit ff1a080

Please sign in to comment.