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 1 commit
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}",
)
3 changes: 3 additions & 0 deletions src/open_inwoner/accounts/views/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
from open_inwoner.openklant.wrap import get_fetch_parameters
from open_inwoner.plans.models import Plan
from open_inwoner.qmatic.client import NoServiceConfigured, QmaticClient
from open_inwoner.qmatic.models import QmaticConfig
from open_inwoner.questionnaire.models import QuestionnaireStep
from open_inwoner.utils.views import CommonPageMixin, LogMixin

Expand Down Expand Up @@ -366,6 +367,8 @@ def get_context_data(self, **kwargs) -> dict[str, Any]:
context["appointments"] = client.list_appointments_for_customer(
self.request.user.email
)
config = QmaticConfig.get_solo()
context["booking_base_url"] = config.booking_base_url
return context

@cached_property
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
16 changes: 5 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,12 @@ <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="{{ booking_base_url }}{{ appointment.publicId }}" class="link link--icon link--secondary"
stevenbal marked this conversation as resolved.
Show resolved Hide resolved
aria-label="{% trans "Wijzig of annuleer afspraak" %}"
title="{% trans "Wijzig of annuleer afspraak" %}">
stevenbal marked this conversation as resolved.
Show resolved Hide resolved
<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