Skip to content

Commit

Permalink
✨ [#2179] Add Mijn afspraken to Mijn profiel
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenbal committed Mar 19, 2024
1 parent ecd7f5b commit 6dd5f69
Show file tree
Hide file tree
Showing 9 changed files with 128 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/open_inwoner/accounts/views/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
from .password_reset import PasswordResetView
from .profile import (
EditProfileView,
MyAppointmentsView,
MyCategoriesView,
MyDataView,
MyNotificationsView,
Expand Down Expand Up @@ -79,6 +80,7 @@
"MyNotificationsView",
"MyProfileView",
"NewsletterSubscribeView",
"MyAppointmentsView",
"CustomRegistrationView",
"NecessaryFieldsUserView",
]
24 changes: 24 additions & 0 deletions src/open_inwoner/accounts/views/profile.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from collections.abc import Generator
from datetime import date
from typing import Any
from urllib.parse import quote

from django.contrib import messages
from django.contrib.auth.mixins import LoginRequiredMixin
Expand Down Expand Up @@ -29,6 +30,7 @@
from open_inwoner.openklant.clients import build_client
from open_inwoner.openklant.wrap import get_fetch_parameters
from open_inwoner.plans.models import Plan
from open_inwoner.qmatic.client import QmaticClient
from open_inwoner.questionnaire.models import QuestionnaireStep
from open_inwoner.utils.views import CommonPageMixin, LogMixin

Expand Down Expand Up @@ -336,3 +338,25 @@ def form_valid(self, form):
self.request.user, _("users newsletter subscriptions were modified")
)
return HttpResponseRedirect(self.get_success_url())


class MyAppointmentsView(
LogMixin, LoginRequiredMixin, CommonPageMixin, BaseBreadcrumbMixin, TemplateView
):
template_name = "pages/profile/appointments.html"

def get_context_data(self, **kwargs) -> dict[str, Any]:
context = super().get_context_data(**kwargs)
# TODO email should be verified
client = QmaticClient()
context["appointments"] = client.list_appointments_for_customer(
quote(self.request.user.email)
)
return context

@cached_property
def crumbs(self):
return [
(_("Mijn profiel"), reverse("profile:detail")),
(_("Mijn afspraken"), reverse("profile:appointments")),
]
1 change: 1 addition & 0 deletions src/open_inwoner/cms/profile/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@ def get_config_fields(self):
"questions",
"ssd",
"newsletters",
"appointments",
)
5 changes: 5 additions & 0 deletions src/open_inwoner/cms/profile/cms_appconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,8 @@ class ProfileConfig(AppHookConfig):
default=False,
help_text=_("Designates whether 'Nieuwsbrieven' section is rendered or not."),
)
appointments = models.BooleanField(
verbose_name=_("Mijn afspraken"),
default=False,
help_text=_("Designates whether 'Mijn afspraken' section is rendered or not."),
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Generated by Django 4.2.10 on 2024-03-18 13:13

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("profile", "0008_profileconfig_newsletters"),
]

operations = [
migrations.AddField(
model_name="profileconfig",
name="appointments",
field=models.BooleanField(
default=False,
help_text="Designates whether 'Mijn afspraken' section is rendered or not.",
verbose_name="Mijn afspraken",
),
),
]
2 changes: 2 additions & 0 deletions src/open_inwoner/cms/profile/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
DocumentPrivateMediaView,
EditProfileView,
InviteAcceptView,
MyAppointmentsView,
MyCategoriesView,
MyDataView,
MyNotificationsView,
Expand Down Expand Up @@ -107,5 +108,6 @@
NewsletterSubscribeView.as_view(),
name="newsletters",
),
path("appointments", MyAppointmentsView.as_view(), name="appointments"),
path("", MyProfileView.as_view(), name="detail"),
]
4 changes: 4 additions & 0 deletions src/open_inwoner/conf/fixtures/django-admin-index.json
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,10 @@
"openzaak",
"catalogusconfig"
],
[
"qmatic",
"qmaticconfig"
],
[
"openzaak",
"openzaakconfig"
Expand Down
52 changes: 52 additions & 0 deletions src/open_inwoner/templates/pages/profile/appointments.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{% extends 'master.html' %}
{% load i18n tz form_tags anchor_menu_tags list_tags icon_tags grid_tags utils %}

{% block content %}

<h1 class="utrecht-heading-1" id="title">{% trans "Mijn afspraken" %}</h2>

{% if appointments %}
<p class="tabled__key">{% trans "Een overzicht van uw afspraken" %}</p>

{% render_grid %}
{% for appointment in appointments %}
{% render_column start=forloop.counter_0|multiply:4 span=4 %}
<div class="card card--compact card--stretch">
<div class="card__body">
{% render_list %}
<span class="contactmomenten-list">
<h2 class="card__heading-2">{{ appointment.title }}</h2>
{% timezone appointment.branch.timeZone %}
{% list_item text=appointment.start|date:"l j F Y H:i" compact=True strong=False %}
{% endtimezone %}
{% list_item text=appointment.notes compact=True strong=False %}
{% list_item text=appointment.branch.name caption=_("Locatie") compact=True strong=False %}
{% list_item text=appointment.branch.addressCity compact=True strong=False %}
{% list_item text=appointment.branch.addressLine2 compact=True strong=False %}
</span>
{% 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>
{% 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>
</div>
</div>
{% endrender_column %}

{% endfor %}
{% endrender_grid %}
</section>
{% else %}
<p class="tabled__key">{% trans "Geen afspraken beschikbaar" %}</p>
{% endif %}

{% endblock %}
19 changes: 16 additions & 3 deletions src/open_inwoner/templates/pages/profile/me.html
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ <h2 class="h2 title" id="notifications">{% trans "Voorkeuren voor meldingen" %}
</div>
</section>

{% if view.config.mentors or view.config.my_contacts or view.config.actions or view.config.ssd or view.config.selfdiagnose or view.config.newsletters %}
{% if view.config.mentors or view.config.my_contacts or view.config.actions or view.config.ssd or view.config.selfdiagnose or view.config.newsletters or view.config.appointments %}
{# Overview #}
<section class="profile-section profile-section__overview">
<h2 class="h2 title" id="overview">{% trans "Overzicht" %}</h2>
Expand Down Expand Up @@ -262,8 +262,21 @@ <h4 class="card__heading-4"><span class="link link__text">{% trans "Zelftest" %}
<h4 class="card__heading-4"><span class="link link__text">{% trans "Nieuwsbrieven" %}</span>
</h4>

<span class="link link--icon link--secondary profile-card__button" aria-label="{% trans "Beijk nieuwsbrieven" %}" title="{% trans "Beijk nieuwsbrieven" %}">
<span class="link__text">{% trans "Beijk nieuwsbrieven" %}</span>
<span class="link link--icon link--secondary profile-card__button" aria-label="{% trans "Bekijk nieuwsbrieven" %}" title="{% trans "Bekijk nieuwsbrieven" %}">
<span class="link__text">{% trans "Bekijk nieuwsbrieven" %}</span>
{% icon icon="arrow_forward" icon_position="after" primary=True outlined=True %}
</span>
</div>
</a>
{% endif %}
{% if view.config.appointments %}
<a href="{% url 'profile:appointments' %}" class="card card--compact card--stretch" id="profile-section-appointments">
<div class="card__body">
<h4 class="card__heading-4"><span class="link link__text">{% trans "Mijn afspraken" %}</span>
</h4>

<span class="link link--icon link--secondary profile-card__button" aria-label="{% trans "Bekijk afspraken" %}" title="{% trans "Bekijk afspraken" %}">
<span class="link__text">{% trans "Bekijk afspraken" %}</span>
{% icon icon="arrow_forward" icon_position="after" primary=True outlined=True %}
</span>
</div>
Expand Down

0 comments on commit 6dd5f69

Please sign in to comment.