From 424d4cfe4d9b4cfeda7d694e298c63cd4c95a50a Mon Sep 17 00:00:00 2001 From: Alex de Landgraaf Date: Fri, 27 Dec 2024 11:56:39 +0100 Subject: [PATCH] [#2935] Mijn Afspraken: Don't show appoinments from the past --- src/open_inwoner/accounts/tests/test_profile_views.py | 4 ++-- src/open_inwoner/cms/plugins/tests/test_appointments.py | 4 ++-- src/open_inwoner/qmatic/client.py | 6 +++++- src/open_inwoner/qmatic/tests/data.py | 4 ++-- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/open_inwoner/accounts/tests/test_profile_views.py b/src/open_inwoner/accounts/tests/test_profile_views.py index cc80ac8fae..61e9419fce 100644 --- a/src/open_inwoner/accounts/tests/test_profile_views.py +++ b/src/open_inwoner/accounts/tests/test_profile_views.py @@ -1495,7 +1495,7 @@ def test_render_list_if_appointments_are_found(self, m): passport_appointment = PQ(cards[0]).find("ul").children() - self.assertEqual(PQ(passport_appointment[0]).text(), "Datum\n1 januari 2020") + self.assertEqual(PQ(passport_appointment[0]).text(), "Datum\n1 januari 2030") self.assertEqual(PQ(passport_appointment[1]).text(), "Tijd\n13:00 uur") self.assertEqual(PQ(passport_appointment[2]).text(), "Locatie\nHoofdkantoor") self.assertEqual(PQ(passport_appointment[3]).text(), "Dam 1") @@ -1509,7 +1509,7 @@ def test_render_list_if_appointments_are_found(self, m): id_card_appointment = PQ(cards[1]).find("ul").children() - self.assertEqual(PQ(id_card_appointment[0]).text(), "Datum\n6 maart 2020") + self.assertEqual(PQ(id_card_appointment[0]).text(), "Datum\n6 maart 2030") self.assertEqual(PQ(id_card_appointment[1]).text(), "Tijd\n11:30 uur") self.assertEqual(PQ(id_card_appointment[2]).text(), "Locatie\nHoofdkantoor") self.assertEqual(PQ(id_card_appointment[3]).text(), "Wall Street 1") diff --git a/src/open_inwoner/cms/plugins/tests/test_appointments.py b/src/open_inwoner/cms/plugins/tests/test_appointments.py index 4473c378ca..2c7195ce97 100644 --- a/src/open_inwoner/cms/plugins/tests/test_appointments.py +++ b/src/open_inwoner/cms/plugins/tests/test_appointments.py @@ -41,9 +41,9 @@ def test_plugin(self, m): aanvraag_id_kaart_date = PQ(items.find("p.tabled__value")[1]).text() aanvraag_id_kaart_title = PQ(items.find(".plugin-card__heading")[1]).text() - self.assertEqual(aanvraag_paspoort_date, "1 januari 2020 om 13:00 uur") + self.assertEqual(aanvraag_paspoort_date, "1 januari 2030 om 13:00 uur") self.assertEqual(aanvraag_paspoort_title, "Paspoort") - self.assertEqual(aanvraag_id_kaart_date, "6 maart 2020 om 11:30 uur") + self.assertEqual(aanvraag_id_kaart_date, "6 maart 2030 om 11:30 uur") self.assertEqual(aanvraag_id_kaart_title, "ID kaart") action_url = items[0].attrib["href"] diff --git a/src/open_inwoner/qmatic/client.py b/src/open_inwoner/qmatic/client.py index 4832551c4d..31620ff578 100644 --- a/src/open_inwoner/qmatic/client.py +++ b/src/open_inwoner/qmatic/client.py @@ -1,5 +1,5 @@ import logging -from datetime import datetime +from datetime import date, datetime from urllib.parse import quote from ape_pie.client import APIClient @@ -144,10 +144,14 @@ def list_appointments_for_customer(self, email: str) -> list[Appointment]: return [] response.raise_for_status() config = QmaticConfig.get_solo() + today = date.today() try: appointments = [ Appointment(**entry) for entry in response.json()["appointmentList"] ] + appointments = [ + entry for entry in appointments if entry.start.date() >= today + ] for appointment in appointments: appointment.url = ( f"{config.booking_base_url}{quote(appointment.publicId)}" diff --git a/src/open_inwoner/qmatic/tests/data.py b/src/open_inwoner/qmatic/tests/data.py index 9d508abb7a..8cdf22a5a9 100644 --- a/src/open_inwoner/qmatic/tests/data.py +++ b/src/open_inwoner/qmatic/tests/data.py @@ -35,7 +35,7 @@ def __init__(self): self.appointment_passport = AppointmentFactory.build( title="Qmatic web booking", - start="2020-01-01T12:00:00+00:00", + start="2030-01-01T12:00:00+00:00", notes="foo", branch=BranchDetailFactory.build( name="Hoofdkantoor", @@ -49,7 +49,7 @@ def __init__(self): ) self.appointment_idcard = AppointmentFactory.build( title="Qmatic web booking", - start="2020-03-06T16:30:00+00:00", + start="2030-03-06T16:30:00+00:00", notes="bar", branch=BranchDetailFactory.build( name="Hoofdkantoor",