Skip to content

Commit 6527cf7

Browse files
committed
✨ [#2180] Add appointment reschedule/delete link in appointment list
task: https://taiga.maykinmedia.nl/project/open-inwoner/task/2180
1 parent a4e7f8c commit 6527cf7

File tree

5 files changed

+48
-11
lines changed

5 files changed

+48
-11
lines changed

src/open_inwoner/accounts/tests/test_profile_views.py

+9
Original file line numberDiff line numberDiff line change
@@ -1157,6 +1157,7 @@ def setUp(self):
11571157
self.user = DigidUserFactory()
11581158

11591159
self.config = QmaticConfig.get_solo()
1160+
self.config.booking_base_url = "https://qmatic.local/"
11601161
self.api_root = "https://qmatic.local/api/"
11611162
self.service = ServiceFactory.create(
11621163
api_root=self.api_root, api_type=APITypes.orc
@@ -1248,6 +1249,10 @@ def test_render_list_if_appointments_are_found(self, m):
12481249
self.assertEqual(PQ(passport_appointment[3]).text(), "Locatie\nHoofdkantoor")
12491250
self.assertEqual(PQ(passport_appointment[4]).text(), "Amsterdam")
12501251
self.assertEqual(PQ(passport_appointment[5]).text(), "Dam 1")
1252+
self.assertEqual(
1253+
PQ(cards[0]).find("a").attr("href"),
1254+
f"{self.config.booking_base_url}{self.appointment_passport.publicId}",
1255+
)
12511256

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

@@ -1259,3 +1264,7 @@ def test_render_list_if_appointments_are_found(self, m):
12591264
self.assertEqual(PQ(id_card_appointment[3]).text(), "Locatie\nHoofdkantoor")
12601265
self.assertEqual(PQ(id_card_appointment[4]).text(), "New York")
12611266
self.assertEqual(PQ(id_card_appointment[5]).text(), "Wall Street 1")
1267+
self.assertEqual(
1268+
PQ(cards[1]).find("a").attr("href"),
1269+
f"{self.config.booking_base_url}{self.appointment_idcard.publicId}",
1270+
)

src/open_inwoner/accounts/views/profile.py

+3
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
from open_inwoner.openklant.wrap import get_fetch_parameters
3333
from open_inwoner.plans.models import Plan
3434
from open_inwoner.qmatic.client import NoServiceConfigured, QmaticClient
35+
from open_inwoner.qmatic.models import QmaticConfig
3536
from open_inwoner.questionnaire.models import QuestionnaireStep
3637
from open_inwoner.utils.views import CommonPageMixin, LogMixin
3738

@@ -367,6 +368,8 @@ def get_context_data(self, **kwargs) -> dict[str, Any]:
367368
context["appointments"] = client.list_appointments_for_customer(
368369
quote(self.request.user.email)
369370
)
371+
config = QmaticConfig.get_solo()
372+
context["booking_base_url"] = config.booking_base_url
370373
return context
371374

372375
@cached_property
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Generated by Django 4.2.10 on 2024-03-21 10:19
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
("qmatic", "0001_initial"),
10+
]
11+
12+
operations = [
13+
migrations.AddField(
14+
model_name="qmaticconfig",
15+
name="booking_base_url",
16+
field=models.URLField(
17+
blank=True,
18+
help_text="The base URL where the user can reschedule or delete their appointment",
19+
max_length=1000,
20+
verbose_name="Booking base URL",
21+
),
22+
),
23+
]

src/open_inwoner/qmatic/models.py

+8
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,14 @@ class QmaticConfig(SingletonModel):
2727
"Example: https://example.com:8443/calendar-backend/public/api/v1/"
2828
),
2929
)
30+
booking_base_url = models.URLField(
31+
verbose_name=_("Booking base URL"),
32+
max_length=1000,
33+
help_text=_(
34+
"The base URL where the user can reschedule or delete their appointment"
35+
),
36+
blank=True,
37+
)
3038

3139
objects = QmaticConfigManager()
3240

src/open_inwoner/templates/pages/profile/appointments.html

+5-11
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,12 @@ <h2 class="card__heading-2">{{ appointment.title }}</h2>
2424
{% list_item text=appointment.branch.addressLine2 compact=True strong=False %}
2525
{% endrender_list %}
2626

27-
<span class="link link--icon link--secondary"
28-
aria-label="{% trans "Wijzig afspraak" %}"
29-
title="{% trans "Wijzig afspraak" %}">
30-
<span class="link__text">{% trans "Wijzig afspraak" %}</span>
27+
<a href="{{ booking_base_url }}{{ appointment.publicId }}" class="link link--icon link--secondary"
28+
aria-label="{% trans "Wijzig of annuleer afspraak" %}"
29+
title="{% trans "Wijzig of annuleer afspraak" %}">
30+
<span class="link__text">{% trans "Wijzig of annuleer afspraak" %}</span>
3131
{% icon icon="arrow_forward" icon_position="after" primary=True outlined=True %}
32-
</span>
33-
<span class="link link--icon link--secondary"
34-
aria-label="{% trans "Annuleer afspraak" %}"
35-
title="{% trans "Annuleer afspraak" %}">
36-
<span class="link__text">{% trans "Annuleer afspraak" %}</span>
37-
{% icon icon="arrow_forward" icon_position="after" primary=True outlined=True %}
38-
</span>
32+
</a>
3933
</div>
4034
</div>
4135
{% endrender_column %}

0 commit comments

Comments
 (0)