diff --git a/manage_breast_screening/clinics/jinja2/clinics/index.jinja b/manage_breast_screening/clinics/jinja2/clinics/index.jinja index cb6a61c44..e00f39e6e 100644 --- a/manage_breast_screening/clinics/jinja2/clinics/index.jinja +++ b/manage_breast_screening/clinics/jinja2/clinics/index.jinja @@ -5,7 +5,10 @@ {% from 'components/secondary-navigation/macro.jinja' import app_secondary_navigation %} {% block page_content %} -

{{ presenter.heading }}

+

+ {{ provider_name }} + {{ presenter.heading }} +

{% set ns = namespace() %} {% set ns.secondaryNavItems = [] %} @@ -37,7 +40,6 @@ Location Date and time - Clinic type Participants Status @@ -56,12 +58,6 @@ {{ presented_clinic.starts_at | no_wrap }}
{{presented_clinic.time_range | as_hint }} - - {{ presented_clinic.type }} -
- {{ presented_clinic.risk_type }} - - {{ presented_clinic.number_of_slots }} diff --git a/manage_breast_screening/clinics/models.py b/manage_breast_screening/clinics/models.py index c0b368ff6..19461c0e9 100644 --- a/manage_breast_screening/clinics/models.py +++ b/manage_breast_screening/clinics/models.py @@ -1,5 +1,5 @@ import uuid -from datetime import date +from datetime import date, timedelta from enum import StrEnum from django.conf import settings @@ -60,7 +60,7 @@ def by_filter(self, filter: str): case ClinicFilter.COMPLETED: return self.completed() case ClinicFilter.ALL: - return self + return self.last_seven_days() case _: raise ValueError(filter) @@ -76,6 +76,9 @@ def upcoming(self): """ return self.filter(starts_at__date__gt=date.today()) + def last_seven_days(self): + return self.filter(starts_at__date__gte=(date.today() - timedelta(days=7))) + def completed(self): """ Completed clinics that started in the past @@ -89,7 +92,8 @@ def completed(self): ) return ( - self.filter(starts_at__date__lt=date.today()) + self.last_seven_days() + .filter(starts_at__date__lt=date.today()) .annotate(latest_status=Subquery(latest_status)) .filter(latest_status__in=["CLOSED", "CANCELLED"]) .order_by("-ends_at") @@ -161,7 +165,7 @@ def filter_counts(cls, provider_id): queryset = cls.objects.filter(setting__provider_id=provider_id) return { - ClinicFilter.ALL: queryset.count(), + ClinicFilter.ALL: queryset.last_seven_days().count(), ClinicFilter.TODAY: queryset.today().count(), ClinicFilter.UPCOMING: queryset.upcoming().count(), ClinicFilter.COMPLETED: queryset.completed().count(), diff --git a/manage_breast_screening/clinics/tests/test_models.py b/manage_breast_screening/clinics/tests/test_models.py index 51ede91bb..46c509bea 100644 --- a/manage_breast_screening/clinics/tests/test_models.py +++ b/manage_breast_screening/clinics/tests/test_models.py @@ -101,6 +101,29 @@ def test_clean_clinic_slots(): clinic_slot.clean() +@time_machine.travel(datetime(2025, 1, 1, 10, tzinfo=tz.utc)) +@pytest.mark.django_db +def test_last_seven_days_all_filtering(): + _clinic1 = ClinicFactory.create( + starts_at=datetime(2024, 12, 1, 9, tzinfo=tz.utc), + ends_at=datetime(2024, 12, 1, 17, tzinfo=tz.utc), + current_status=models.ClinicStatus.CLOSED, + ) + _clinic2 = ClinicFactory.create( + starts_at=datetime(2024, 12, 2, 9, tzinfo=tz.utc), + ends_at=datetime(2024, 12, 2, 17, tzinfo=tz.utc), + current_status=models.ClinicStatus.CLOSED, + ) + clinic3 = ClinicFactory.create( + starts_at=datetime(2024, 12, 29, 9, tzinfo=tz.utc), + ends_at=datetime(2024, 12, 29, 17, tzinfo=tz.utc), + current_status=models.ClinicStatus.CLOSED, + ) + + last_seven_days_clinics = models.Clinic.objects.last_seven_days() + assertQuerySetEqual(last_seven_days_clinics, [clinic3]) + + class TestUserAssignment: def test_str(self): user = UserFactory.build(first_name="John", last_name="Doe") diff --git a/manage_breast_screening/clinics/views.py b/manage_breast_screening/clinics/views.py index a746a1d5d..1b8eb734f 100644 --- a/manage_breast_screening/clinics/views.py +++ b/manage_breast_screening/clinics/views.py @@ -18,7 +18,11 @@ def clinic_list(request, filter="today"): return render( request, "clinics/index.jinja", - context={"presenter": presenter, "page_title": presenter.heading}, + context={ + "presenter": presenter, + "page_title": presenter.heading, + "provider_name": provider.name, + }, ) diff --git a/manage_breast_screening/tests/system/clinical/test_clinic_show_page.py b/manage_breast_screening/tests/system/clinical/test_clinic_show_page.py index 9d9edc360..2fe49b18f 100644 --- a/manage_breast_screening/tests/system/clinical/test_clinic_show_page.py +++ b/manage_breast_screening/tests/system/clinical/test_clinic_show_page.py @@ -115,6 +115,8 @@ def and_there_are_appointments(self): def and_i_am_on_the_clinic_list(self): self.page.goto(self.live_server_url + reverse("clinics:index")) self.assert_page_title_contains("Today’s clinics") + heading = self.page.get_by_role("heading", level=1) + expect(heading).to_contain_text(self.current_provider.name) def and_i_am_on_the_clinic_show_page(self): self.page.goto(