Skip to content

Commit 28b45d6

Browse files
Merge pull request #852 from NHSDigital/DTOSS-11864-snagging-updates
Snagging updates
2 parents 8f9a89e + 96492fe commit 28b45d6

File tree

5 files changed

+42
-13
lines changed

5 files changed

+42
-13
lines changed

manage_breast_screening/clinics/jinja2/clinics/index.jinja

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55
{% from 'components/secondary-navigation/macro.jinja' import app_secondary_navigation %}
66

77
{% block page_content %}
8-
<h1>{{ presenter.heading }}</h1>
8+
<h1>
9+
<span class="nhsuk-caption-l"> {{ provider_name }} </span>
10+
{{ presenter.heading }}
11+
</h1>
912

1013
{% set ns = namespace() %}
1114
{% set ns.secondaryNavItems = [] %}
@@ -37,7 +40,6 @@
3740
<tr>
3841
<th scope="col">Location</th>
3942
<th scope="col">Date and time</th>
40-
<th scope="col">Clinic type</th>
4143
<th scope="col" class="nhsuk-table__cell--numeric">Participants</th>
4244
<th scope="col">Status</th>
4345
</tr>
@@ -56,12 +58,6 @@
5658
<td>{{ presented_clinic.starts_at | no_wrap }}<br>
5759
{{presented_clinic.time_range | as_hint }}
5860
</td>
59-
<td>
60-
{{ presented_clinic.type }}
61-
<br>
62-
<span class="nhsuk-u-secondary-text-color">{{ presented_clinic.risk_type }}</span>
63-
</td>
64-
6561
<td class="nhsuk-table__cell--numeric">
6662
{{ presented_clinic.number_of_slots }}
6763
</td>

manage_breast_screening/clinics/models.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import uuid
2-
from datetime import date
2+
from datetime import date, timedelta
33
from enum import StrEnum
44

55
from django.conf import settings
@@ -60,7 +60,7 @@ def by_filter(self, filter: str):
6060
case ClinicFilter.COMPLETED:
6161
return self.completed()
6262
case ClinicFilter.ALL:
63-
return self
63+
return self.last_seven_days()
6464
case _:
6565
raise ValueError(filter)
6666

@@ -76,6 +76,9 @@ def upcoming(self):
7676
"""
7777
return self.filter(starts_at__date__gt=date.today())
7878

79+
def last_seven_days(self):
80+
return self.filter(starts_at__date__gte=(date.today() - timedelta(days=7)))
81+
7982
def completed(self):
8083
"""
8184
Completed clinics that started in the past
@@ -89,7 +92,8 @@ def completed(self):
8992
)
9093

9194
return (
92-
self.filter(starts_at__date__lt=date.today())
95+
self.last_seven_days()
96+
.filter(starts_at__date__lt=date.today())
9397
.annotate(latest_status=Subquery(latest_status))
9498
.filter(latest_status__in=["CLOSED", "CANCELLED"])
9599
.order_by("-ends_at")
@@ -161,7 +165,7 @@ def filter_counts(cls, provider_id):
161165
queryset = cls.objects.filter(setting__provider_id=provider_id)
162166

163167
return {
164-
ClinicFilter.ALL: queryset.count(),
168+
ClinicFilter.ALL: queryset.last_seven_days().count(),
165169
ClinicFilter.TODAY: queryset.today().count(),
166170
ClinicFilter.UPCOMING: queryset.upcoming().count(),
167171
ClinicFilter.COMPLETED: queryset.completed().count(),

manage_breast_screening/clinics/tests/test_models.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,29 @@ def test_clean_clinic_slots():
101101
clinic_slot.clean()
102102

103103

104+
@time_machine.travel(datetime(2025, 1, 1, 10, tzinfo=tz.utc))
105+
@pytest.mark.django_db
106+
def test_last_seven_days_all_filtering():
107+
_clinic1 = ClinicFactory.create(
108+
starts_at=datetime(2024, 12, 1, 9, tzinfo=tz.utc),
109+
ends_at=datetime(2024, 12, 1, 17, tzinfo=tz.utc),
110+
current_status=models.ClinicStatus.CLOSED,
111+
)
112+
_clinic2 = ClinicFactory.create(
113+
starts_at=datetime(2024, 12, 2, 9, tzinfo=tz.utc),
114+
ends_at=datetime(2024, 12, 2, 17, tzinfo=tz.utc),
115+
current_status=models.ClinicStatus.CLOSED,
116+
)
117+
clinic3 = ClinicFactory.create(
118+
starts_at=datetime(2024, 12, 29, 9, tzinfo=tz.utc),
119+
ends_at=datetime(2024, 12, 29, 17, tzinfo=tz.utc),
120+
current_status=models.ClinicStatus.CLOSED,
121+
)
122+
123+
last_seven_days_clinics = models.Clinic.objects.last_seven_days()
124+
assertQuerySetEqual(last_seven_days_clinics, [clinic3])
125+
126+
104127
class TestUserAssignment:
105128
def test_str(self):
106129
user = UserFactory.build(first_name="John", last_name="Doe")

manage_breast_screening/clinics/views.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ def clinic_list(request, filter="today"):
1818
return render(
1919
request,
2020
"clinics/index.jinja",
21-
context={"presenter": presenter, "page_title": presenter.heading},
21+
context={
22+
"presenter": presenter,
23+
"page_title": presenter.heading,
24+
"provider_name": provider.name,
25+
},
2226
)
2327

2428

manage_breast_screening/tests/system/clinical/test_clinic_show_page.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ def and_there_are_appointments(self):
115115
def and_i_am_on_the_clinic_list(self):
116116
self.page.goto(self.live_server_url + reverse("clinics:index"))
117117
self.assert_page_title_contains("Today’s clinics")
118+
heading = self.page.get_by_role("heading", level=1)
119+
expect(heading).to_contain_text(self.current_provider.name)
118120

119121
def and_i_am_on_the_clinic_show_page(self):
120122
self.page.goto(

0 commit comments

Comments
 (0)