Skip to content

Commit 3e845fd

Browse files
authored
Merge pull request #1133 from alphagov/2121-show-all-detailed-reminders
2121: Add option to show all undeleted detailed reminders on Task list
2 parents d6d6c58 + b7839a8 commit 3e845fd

3 files changed

Lines changed: 67 additions & 0 deletions

File tree

accessibility_monitoring_platform/apps/notifications/templates/notifications/task_list.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,13 @@ <h1 class="govuk-heading-xl amp-margin-bottom-30">{{ sitemap.current_platform_pa
132132
<a href="?type=reminder&future=true" class="govuk-link govuk-link--no-visited-state govuk-link--no-underline">View future</a>
133133
{% endif %}
134134
</li>
135+
<li class="amp-custom-nav-bar amp-margin-right-25">
136+
{% if show_all_detailed_reminders %}
137+
<b> All detailed </b>
138+
{% else %}
139+
<a href="?type=reminder&show_all_detailed_reminders=true" class="govuk-link govuk-link--no-visited-state govuk-link--no-underline">All detailed</a>
140+
{% endif %}
141+
</li>
135142
</ul>
136143
{% endif %}
137144
</div>

accessibility_monitoring_platform/apps/notifications/tests/test_views.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -698,3 +698,51 @@ def test_deactivate_case_updates_status(admin_client):
698698
)
699699

700700
assert simplified_case_from_db.status == SimplifiedCase.Status.DEACTIVATED
701+
702+
703+
@pytest.mark.django_db
704+
def test_task_list_show_all_detailed_reminders(rf):
705+
"""Test task list page can show all due reminder tasks for detailed cases"""
706+
request_user: User = User.objects.create(
707+
username="mockuser1", email="mockuser1@mock.com", password="secret1"
708+
)
709+
other_user: User = User.objects.create(
710+
username="mockuser2", email="mockuser2@mock.com", password="secret2"
711+
)
712+
simplified_case: SimplifiedCase = SimplifiedCase.objects.create(auditor=other_user)
713+
Task.objects.create(
714+
type=Task.Type.REMINDER,
715+
date=date.today(),
716+
user=request_user,
717+
base_case=simplified_case,
718+
description="Simplified reminder description",
719+
)
720+
detailed_case: DetailedCase = DetailedCase.objects.create(auditor=other_user)
721+
Task.objects.create(
722+
type=Task.Type.REMINDER,
723+
date=date.today(),
724+
user=request_user,
725+
base_case=detailed_case,
726+
description="First detailed reminder description",
727+
)
728+
Task.objects.create(
729+
type=Task.Type.REMINDER,
730+
date=date.today(),
731+
user=other_user,
732+
base_case=detailed_case,
733+
description="Second detailed reminder description",
734+
)
735+
736+
request: HttpRequest = rf.get(
737+
f'{reverse("notifications:task-list")}?type=reminder&show_all_detailed_reminders=true'
738+
)
739+
request.user = request_user
740+
741+
response: HttpResponse = TaskListView.as_view()(request)
742+
743+
assert response.status_code == 200
744+
745+
assertContains(response, "Tasks (2)")
746+
assertContains(response, "First detailed reminder description")
747+
assertContains(response, "Second detailed reminder description")
748+
assertNotContains(response, "Simplified reminder description")

accessibility_monitoring_platform/apps/notifications/views.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
from django.contrib import messages
66
from django.contrib.auth.models import User
7+
from django.db.models.query import QuerySet
78
from django.forms.models import ModelForm
89
from django.http import HttpResponseRedirect
910
from django.urls import reverse, reverse_lazy
@@ -44,6 +45,17 @@ def get_context_data(self, **kwargs) -> dict[str, Any]:
4445
context["task_type_counts"] = get_task_type_counts(tasks=tasks)
4546
return {**context, **params}
4647

48+
if "show_all_detailed_reminders" in self.request.GET:
49+
tasks: QuerySet[Task] = Task.objects.filter(
50+
type=Task.Type.REMINDER,
51+
base_case__test_type=BaseCase.TestType.DETAILED,
52+
read=False,
53+
).order_by("date")
54+
context["tasks"] = tasks
55+
context["show_all_detailed_reminders"] = True
56+
context["task_type_counts"] = get_task_type_counts(tasks=tasks)
57+
return {**context, **params}
58+
4759
user: User = self.request.user
4860

4961
# Check for parameter to list another user's Tasks. Useful for live support.

0 commit comments

Comments
 (0)