Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ [#2180] Implement reschedule and delete for Qmatic appointments #1103

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/open_inwoner/accounts/tests/test_profile_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1157,6 +1157,7 @@ def setUp(self):
self.user = DigidUserFactory()

self.config = QmaticConfig.get_solo()
self.config.booking_base_url = "https://qmatic.local/"
self.api_root = "https://qmatic.local/api/"
self.service = ServiceFactory.create(
api_root=self.api_root, api_type=APITypes.orc
Expand Down Expand Up @@ -1258,6 +1259,10 @@ def test_render_list_if_appointments_are_found(self, m):
self.assertEqual(PQ(passport_appointment[3]).text(), "Locatie\nHoofdkantoor")
self.assertEqual(PQ(passport_appointment[4]).text(), "Amsterdam")
self.assertEqual(PQ(passport_appointment[5]).text(), "Dam 1")
self.assertEqual(
PQ(cards[0]).find("a").attr("href"),
f"{self.config.booking_base_url}{self.appointment_passport.publicId}",
)

id_card_appointment = PQ(cards[1]).find("ul").children()

Expand All @@ -1269,3 +1274,7 @@ def test_render_list_if_appointments_are_found(self, m):
self.assertEqual(PQ(id_card_appointment[3]).text(), "Locatie\nHoofdkantoor")
self.assertEqual(PQ(id_card_appointment[4]).text(), "New York")
self.assertEqual(PQ(id_card_appointment[5]).text(), "Wall Street 1")
self.assertEqual(
PQ(cards[1]).find("a").attr("href"),
f"{self.config.booking_base_url}{self.appointment_idcard.publicId}",
)
9 changes: 8 additions & 1 deletion src/open_inwoner/qmatic/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class BranchDetail(BaseModel):


class Appointment(JSONEncoderMixin, BaseModel):
url: str | None
services: list[QmaticService]
title: str
start: datetime
Expand Down Expand Up @@ -135,10 +136,16 @@ def list_appointments_for_customer(
if response.status_code == 404:
return []
response.raise_for_status()
config = QmaticConfig.get_solo()
try:
return [
appointments = [
Appointment(**entry) for entry in response.json()["appointmentList"]
]
for appointment in appointments:
appointment.url = (
f"{config.booking_base_url}{quote(appointment.publicId)}"
Bartvaderkin marked this conversation as resolved.
Show resolved Hide resolved
)
return appointments
except ValidationError:
logger.exception(
"Something went wrong while deserializing appointment data"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 4.2.10 on 2024-03-21 10:19

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("qmatic", "0001_initial"),
]

operations = [
migrations.AddField(
model_name="qmaticconfig",
name="booking_base_url",
field=models.URLField(
blank=True,
help_text="The base URL where the user can reschedule or delete their appointment",
max_length=1000,
verbose_name="Booking base URL",
),
),
]
8 changes: 8 additions & 0 deletions src/open_inwoner/qmatic/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ class QmaticConfig(SingletonModel):
"Example: https://example.com:8443/calendar-backend/public/api/v1/"
),
)
booking_base_url = models.URLField(
verbose_name=_("Booking base URL"),
max_length=1000,
help_text=_(
"The base URL where the user can reschedule or delete their appointment"
),
blank=True,
)

objects = QmaticConfigManager()

Expand Down
15 changes: 4 additions & 11 deletions src/open_inwoner/templates/pages/profile/appointments.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,11 @@ <h2 class="card__heading-2">{{ appointment.title }}</h2>
{% list_item text=appointment.branch.addressLine2 compact=True strong=False %}
{% endrender_list %}

<span class="link link--icon link--secondary"
aria-label="{% trans "Wijzig afspraak" %}"
title="{% trans "Wijzig afspraak" %}">
<span class="link__text">{% trans "Wijzig afspraak" %}</span>
<a href="{{ appointment.url }}" class="link link--icon link--secondary"
title="{% trans "Wijzig of annuleer afspraak" %}">
<span class="link__text">{% trans "Wijzig of annuleer afspraak" %}</span>
{% icon icon="arrow_forward" icon_position="after" primary=True outlined=True %}
</span>
<span class="link link--icon link--secondary"
aria-label="{% trans "Annuleer afspraak" %}"
title="{% trans "Annuleer afspraak" %}">
<span class="link__text">{% trans "Annuleer afspraak" %}</span>
{% icon icon="arrow_forward" icon_position="after" primary=True outlined=True %}
</span>
</a>
</div>
</div>
{% endrender_column %}
Expand Down
Loading