From 22f3abe2c23c4dc892538541b5fa9a1b496153b5 Mon Sep 17 00:00:00 2001 From: Sidney Richards Date: Tue, 8 Oct 2024 14:15:23 +0200 Subject: [PATCH 1/9] Add objects-api-client-django pinned to Hackathon branch --- requirements/base.in | 4 ++++ requirements/base.txt | 6 ++++++ requirements/ci.txt | 8 ++++++++ requirements/dev.txt | 8 ++++++++ src/open_inwoner/conf/base.py | 1 + 5 files changed, 27 insertions(+) diff --git a/requirements/base.in b/requirements/base.in index 0855ed7173..912c78f91e 100644 --- a/requirements/base.in +++ b/requirements/base.in @@ -94,6 +94,10 @@ git+/~https://github.com/maykinmedia/django-celery-monitor@513dc28#egg=django_cele zgw-consumers zgw-consumers-oas notifications-api-common +git+/~https://github.com/maykinmedia/objects-api-client-django.git@f499caf#egg=objects-api-client-django + + + # 2FA SMS verification oath diff --git a/requirements/base.txt b/requirements/base.txt index cb1abc7756..8e38c0e890 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -146,6 +146,7 @@ django==4.2.16 # mozilla-django-oidc # mozilla-django-oidc-db # notifications-api-common + # objects-api-client-django # zgw-consumers # zgw-consumers-oas django-admin-index==3.1.0 @@ -272,6 +273,7 @@ django-solo==2.2.0 # django-open-forms-client # mozilla-django-oidc-db # notifications-api-common + # objects-api-client-django # zgw-consumers django-timeline-logger==3.0.0 # via -r requirements/base.in @@ -411,6 +413,8 @@ notifications-api-common==0.2.2 # via -r requirements/base.in oath==1.4.4 # via -r requirements/base.in +objects-api-client-django @ git+/~https://github.com/maykinmedia/objects-api-client-django.git@f499caf + # via -r requirements/base.in odfpy==1.4.1 # via tablib openpyxl==3.0.9 @@ -508,6 +512,7 @@ requests==2.31.0 # maykin-python3-saml # messagebird # mozilla-django-oidc + # objects-api-client-django # zgw-consumers sentry-sdk==1.38.0 # via -r requirements/base.in @@ -594,6 +599,7 @@ zgw-consumers==0.35.1 # via # -r requirements/base.in # notifications-api-common + # objects-api-client-django zgw-consumers-oas==1.0.0 # via -r requirements/base.in zopfli==0.1.9 diff --git a/requirements/ci.txt b/requirements/ci.txt index 19c6e61162..c2b7eb052b 100644 --- a/requirements/ci.txt +++ b/requirements/ci.txt @@ -238,6 +238,7 @@ django==4.2.16 # mozilla-django-oidc # mozilla-django-oidc-db # notifications-api-common + # objects-api-client-django # zgw-consumers # zgw-consumers-oas django-admin-index==3.1.0 @@ -460,6 +461,7 @@ django-solo==2.2.0 # django-open-forms-client # mozilla-django-oidc-db # notifications-api-common + # objects-api-client-django # zgw-consumers django-timeline-logger==3.0.0 # via @@ -764,6 +766,10 @@ oath==1.4.4 # via # -c requirements/base.txt # -r requirements/base.txt +objects-api-client-django @ git+/~https://github.com/maykinmedia/objects-api-client-django.git@f499caf + # via + # -c requirements/base.txt + # -r requirements/base.txt odfpy==1.4.1 # via # -c requirements/base.txt @@ -973,6 +979,7 @@ requests==2.31.0 # maykin-python3-saml # messagebird # mozilla-django-oidc + # objects-api-client-django # requests-mock # sphinx # zgw-consumers @@ -1167,6 +1174,7 @@ zgw-consumers==0.35.1 # -c requirements/base.txt # -r requirements/base.txt # notifications-api-common + # objects-api-client-django zgw-consumers-oas==1.0.0 # via # -c requirements/base.txt diff --git a/requirements/dev.txt b/requirements/dev.txt index 3da20986db..10b67485b8 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -278,6 +278,7 @@ django==4.2.16 # mozilla-django-oidc # mozilla-django-oidc-db # notifications-api-common + # objects-api-client-django # zgw-consumers # zgw-consumers-oas django-admin-index==3.1.0 @@ -506,6 +507,7 @@ django-solo==2.2.0 # django-open-forms-client # mozilla-django-oidc-db # notifications-api-common + # objects-api-client-django # zgw-consumers django-timeline-logger==3.0.0 # via @@ -874,6 +876,10 @@ oath==1.4.4 # via # -c requirements/ci.txt # -r requirements/ci.txt +objects-api-client-django @ git+/~https://github.com/maykinmedia/objects-api-client-django.git@f499caf + # via + # -c requirements/ci.txt + # -r requirements/ci.txt odfpy==1.4.1 # via # -c requirements/ci.txt @@ -1125,6 +1131,7 @@ requests==2.31.0 # maykin-python3-saml # messagebird # mozilla-django-oidc + # objects-api-client-django # requests-mock # sphinx # zgw-consumers @@ -1390,6 +1397,7 @@ zgw-consumers==0.35.1 # -c requirements/ci.txt # -r requirements/ci.txt # notifications-api-common + # objects-api-client-django zgw-consumers-oas==1.0.0 # via # -c requirements/ci.txt diff --git a/src/open_inwoner/conf/base.py b/src/open_inwoner/conf/base.py index 0e8c9c54d5..b84363be8a 100644 --- a/src/open_inwoner/conf/base.py +++ b/src/open_inwoner/conf/base.py @@ -204,6 +204,7 @@ "django_setup_configuration", "django_yubin", "notifications", + "objectsapiclient", # Project applications. "open_inwoner.components", "open_inwoner.kvk", From 61abd02f471f0375a55a9ef10be960af60b0eaa7 Mon Sep 17 00:00:00 2001 From: Sidney Richards Date: Tue, 8 Oct 2024 14:49:32 +0200 Subject: [PATCH 2/9] Connect Berichten views to Objects API --- src/open_inwoner/berichten/api_models.py | 11 ++-- src/open_inwoner/berichten/mock_data.py | 63 ------------------- src/open_inwoner/berichten/services.py | 41 ++++++++++++ .../berichten/views/bericht_detail.py | 5 +- .../berichten/views/bericht_list.py | 7 ++- .../templates/pages/berichten/detail.html | 4 +- .../templates/pages/berichten/list.html | 2 +- 7 files changed, 58 insertions(+), 75 deletions(-) delete mode 100644 src/open_inwoner/berichten/mock_data.py create mode 100644 src/open_inwoner/berichten/services.py diff --git a/src/open_inwoner/berichten/api_models.py b/src/open_inwoner/berichten/api_models.py index 117bb9dd02..42f78d11d3 100644 --- a/src/open_inwoner/berichten/api_models.py +++ b/src/open_inwoner/berichten/api_models.py @@ -7,7 +7,7 @@ from datetime import date from typing import List, Optional -from pydantic import AnyUrl, BaseModel, Field, constr +from pydantic import BaseModel, Field, constr from typing_extensions import Literal @@ -19,7 +19,7 @@ class Identificatie(BaseModel): class Bericht(BaseModel): object_uuid: str = Field(..., description="UUID van het onderliggende object") onderwerp: str = Field(..., description="Onderwerp van het bericht") - berichtTekst: str = Field( + bericht_tekst: str = Field( ..., description="Tekst van het bericht. Mag URL bevatten en /r/n voor newline. Geen verdere opmaak mogelijk.", ) @@ -27,7 +27,7 @@ class Bericht(BaseModel): ..., description="Tijdstip van verwerken van het bericht of de PublicatieDatum indien deze is ingevuld", ) - einddatumHandelingstermijn: Optional[date] = Field( + einddatum_handelingstermijn: Optional[date] = Field( None, description="Termijn waarbinnen de geadresseerde moet reageren" ) referentie: Optional[str] = Field(None, description="TODO") @@ -38,11 +38,12 @@ class Bericht(BaseModel): ..., description="Het bericht is door de geadresseerde geopend of nog niet geopend", ) - berichtType: Literal[ + bericht_type: Literal[ "notificatie", "betaalverzoek", "uitnodiging", "verzoek", "TODO" ] = Field(..., description="Type bericht") identificatie: Identificatie = Field(..., description="TODO") - bijlages: List[AnyUrl] = Field( + # TODO: Should be AnyUrl + bijlages: List[str] = Field( ..., description="TODO", examples=[["https://documenten.nl/api/v1/enkelvoudiginformatieobjecten/1"]], diff --git a/src/open_inwoner/berichten/mock_data.py b/src/open_inwoner/berichten/mock_data.py deleted file mode 100644 index e0ddc1d394..0000000000 --- a/src/open_inwoner/berichten/mock_data.py +++ /dev/null @@ -1,63 +0,0 @@ -import uuid -from datetime import date - -from open_inwoner.berichten.api_models import Bericht - -MOCK_BERICHT_1 = { - "onderwerp": "Besluit 1", - "berichtTekst": "Hallo,\neen\nbericht 1", - "publicatiedatum": date.fromisoformat("2024-01-01"), - "referentie": "TODO", - "handelingsperspectief": "TODO", - "einddatumHandelingstermijn": date.fromisoformat("2024-12-01"), - "geopend": False, - "berichtType": "TODO", - "identificatie": {"type": "bsn", "value": "999991954"}, - "bijlages": [ - "https://documenten.nl/api/v1/enkelvoudiginformatieobjecten/1", - "https://documenten.nl/api/v1/enkelvoudiginformatieobjecten/2", - ], -} - -MOCK_BERICHT_2 = { - "onderwerp": "Voorbeeld onderwerp", - "berichtTekst": "Goedendag,\nwederom een\n2e bericht", - "publicatiedatum": date.fromisoformat("2024-01-02"), - "referentie": "notificatie", - "handelingsperspectief": "informatie ontvangen", - "einddatumHandelingstermijn": date.fromisoformat("2024-12-02"), - "geopend": False, - "berichtType": "notificatie", - "identificatie": {"type": "bsn", "value": "999991955"}, - "bijlages": [ - "https://documenten.nl/api/v1/enkelvoudiginformatieobjecten/3", - "https://documenten.nl/api/v1/enkelvoudiginformatieobjecten/4", - ], -} - -MOCK_BERICHT_3 = { - "onderwerp": "Betalen van uw parkeerbon", - "berichtTekst": "Hallo,\neen\nbericht 3", - "publicatiedatum": date.fromisoformat("2024-01-03"), - "referentie": "TODO 3", - "handelingsperspectief": "betalen", - "einddatumHandelingstermijn": date.fromisoformat("2024-12-03"), - "geopend": True, - "berichtType": "betaalverzoek", - "identificatie": {"type": "bsn", "value": "999991956"}, - "bijlages": [ - "https://documenten.nl/api/v1/enkelvoudiginformatieobjecten/5", - "https://documenten.nl/api/v1/enkelvoudiginformatieobjecten/6", - ], -} - -MOCK_BERICHTEN = [ - Bericht.model_validate(MOCK_BERICHT_1 | {"object_uuid": str(uuid.uuid4())}), - Bericht.model_validate(MOCK_BERICHT_2 | {"object_uuid": str(uuid.uuid4())}), - Bericht.model_validate(MOCK_BERICHT_3 | {"object_uuid": str(uuid.uuid4())}), -] - -MOCK_BERICHTEN *= (25 // len(MOCK_BERICHTEN)) + 1 - -# Slice -MOCK_BERICHTEN = MOCK_BERICHTEN[:25] diff --git a/src/open_inwoner/berichten/services.py b/src/open_inwoner/berichten/services.py new file mode 100644 index 0000000000..f499147bc6 --- /dev/null +++ b/src/open_inwoner/berichten/services.py @@ -0,0 +1,41 @@ +from typing import Literal + +from objectsapiclient.client import Client as ObjectenClient +from objectsapiclient.models import Configuration + +from open_inwoner.berichten.api_models import Bericht + + +class BerichtenService: + + client: ObjectenClient + + def __init__(self, client: ObjectenClient | None = None): + self.client = client or Configuration.get_solo().client + + def fetch_berichten_for_bsn(self, bsn: str): + return self.fetch_berichten_for_identificatie("bsn", bsn) + + def fetch_berichten_for_kvk(self, kvk: str): + return self.fetch_berichten_for_identificatie("kvk", kvk) + + def fetch_berichten_for_identificatie( + self, identificatie_type: Literal["bsn", "kvk"], identificatie_value: str + ): + objects = self.client.get_objects( + object_type_uuid="98b9b5dd-9c2c-44ba-b5bf-13edaed668f9", + data_attrs=[ + f"identificatie__type__exact__{identificatie_type}", + f"identificatie__value__exact__{identificatie_value}", + ], + ) + + return [ + Bericht.model_validate(obj.record["data"] | {"object_uuid": obj.uuid}) + for obj in objects + ] + + def fetch_bericht(self, uuid: str): + obj = self.client.get_object(uuid) + + return Bericht.model_validate(obj.record["data"] | {"object_uuid": obj.uuid}) diff --git a/src/open_inwoner/berichten/views/bericht_detail.py b/src/open_inwoner/berichten/views/bericht_detail.py index 828f037fae..715ace9b31 100644 --- a/src/open_inwoner/berichten/views/bericht_detail.py +++ b/src/open_inwoner/berichten/views/bericht_detail.py @@ -7,7 +7,7 @@ from view_breadcrumbs import BaseBreadcrumbMixin -from open_inwoner.berichten.mock_data import MOCK_BERICHTEN +from open_inwoner.berichten.services import BerichtenService from open_inwoner.utils.views import CommonPageMixin logger = logging.getLogger(__name__) @@ -29,5 +29,6 @@ def page_title(self): def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) - context["bericht"] = MOCK_BERICHTEN[0] + service = BerichtenService() + context["bericht"] = service.fetch_bericht(self.kwargs["object_uuid"]) return context diff --git a/src/open_inwoner/berichten/views/bericht_list.py b/src/open_inwoner/berichten/views/bericht_list.py index 698b3e5e5e..8c10a6f9f1 100644 --- a/src/open_inwoner/berichten/views/bericht_list.py +++ b/src/open_inwoner/berichten/views/bericht_list.py @@ -7,7 +7,7 @@ from view_breadcrumbs import BaseBreadcrumbMixin -from open_inwoner.berichten.mock_data import MOCK_BERICHTEN +from open_inwoner.berichten.services import BerichtenService from open_inwoner.utils.views import CommonPageMixin logger = logging.getLogger(__name__) @@ -28,5 +28,8 @@ def page_title(self): def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) - context["berichten"] = MOCK_BERICHTEN + service = BerichtenService() + if self.request.user.is_authenticated and (bsn := self.request.user.bsn): + context["berichten"] = service.fetch_berichten_for_bsn(bsn) + return context diff --git a/src/open_inwoner/templates/pages/berichten/detail.html b/src/open_inwoner/templates/pages/berichten/detail.html index 87ef61adb9..83bd3da0d5 100644 --- a/src/open_inwoner/templates/pages/berichten/detail.html +++ b/src/open_inwoner/templates/pages/berichten/detail.html @@ -35,7 +35,7 @@

berichtTekst:
- {{ bericht.berichtTekst|linebreaks }}

+ {{ bericht.bericht_tekst|linebreaks }}

handelingsperspectief: {{ bericht.handelingsperspectief }}
@@ -67,7 +67,7 @@

Bijlagen

-{% endblock %} + {% else %} +

{% trans 'Dit bericht is momenteel niet beschikbaar.' %}

+ {% endif %} +{% endblock content %} diff --git a/src/open_inwoner/templates/pages/berichten/list.html b/src/open_inwoner/templates/pages/berichten/list.html index 5e49048462..44b25c5880 100644 --- a/src/open_inwoner/templates/pages/berichten/list.html +++ b/src/open_inwoner/templates/pages/berichten/list.html @@ -1,5 +1,5 @@ {% extends 'master.html' %} -{% load i18n button_tags card_tags map_tags utils icon_tags file_tags action_tags dropdown_tags anchor_menu_tags %} +{% load i18n button_tags card_tags map_tags utils icon_tags file_tags action_tags dropdown_tags anchor_menu_tags file_tags %} {% block content %} @@ -25,24 +25,32 @@

{% endif %} {% for bericht in berichten %} - + {{ bericht.onderwerp }} - {{ bericht.publicatiedatum }} + + + {{ bericht.publicatiedatum }} - + - {{ bericht.bericht_type }} - + + + {{ bericht.bericht_type }} + From df3bdce9ce126328046eb1f92432d420028a07ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cjiromaykin=E2=80=9D?= Date: Wed, 9 Oct 2024 17:47:52 +0200 Subject: [PATCH 4/9] [#2799] Improved list template --- .../templates/pages/berichten/list.html | 165 ++++++------------ 1 file changed, 58 insertions(+), 107 deletions(-) diff --git a/src/open_inwoner/templates/pages/berichten/list.html b/src/open_inwoner/templates/pages/berichten/list.html index 1ef317485e..44b25c5880 100644 --- a/src/open_inwoner/templates/pages/berichten/list.html +++ b/src/open_inwoner/templates/pages/berichten/list.html @@ -1,118 +1,69 @@ {% extends 'master.html' %} -{% load i18n grid_tags button_tags icon_tags %} +{% load i18n button_tags card_tags map_tags utils icon_tags file_tags action_tags dropdown_tags anchor_menu_tags file_tags %} {% block content %} - {% if bericht %} - {% render_grid %} - {% render_column span=12 %} -

{{ bericht.onderwerp }}

- - {% endrender_column %} - {% endrender_grid %} - {% render_grid %} - {% render_column start=4 span=6 %} -
- -
- {# End of handelingsperspectief alert #} +
+

+ Mijn berichten +

+

Welkom in uw berichtencentrum. Hier vindt u een overzicht van uw notificaties.

-
-
-

{{ bericht.bericht_tekst|linebreaks }}

-
+
+ + + + + + + + + + + {% if not berichten %} + {% trans "U heeft op dit moment nog geen berichten." %} + {% endif %} + {% for bericht in berichten %} + + + + + + + {% endfor %} - {% if bericht.bijlages %} -
-
-

Bijlagen

-
-
-
    - {% for attachment in bericht.bijlages %} -
  • - -
  • - {% endfor %} -
-
-
- {% else %} -

{% trans 'Er zijn geen bijlagen bij dit bericht.' %}

- {% endif %} + +
OnderwerpEinddatumStatusBericht type
+ + {{ bericht.onderwerp }} + + + + {{ bericht.publicatiedatum }} + + {% if bericht.geopend %} +
+ Geopend +
+ {% else %} +
+ Niet geopend +
+ {% endif %} +
+
+ + {{ bericht.bericht_type }} - - {% if destination %} - - {% endif %} - +
- {% endrender_column %} - {% endrender_grid %} + {# end service list#} +
- {% else %} -

{% trans 'Dit bericht is momenteel niet beschikbaar.' %}

- {% endif %} -{% endblock content %} +
+{% endblock %} From 9db01c01d38c0415020cc918360214076ced610d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cjiromaykin=E2=80=9D?= Date: Wed, 9 Oct 2024 17:54:39 +0200 Subject: [PATCH 5/9] [#2799] Adjusted breadcrumb --- src/open_inwoner/berichten/views/bericht_detail.py | 2 +- src/open_inwoner/templates/pages/berichten/detail.html | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/open_inwoner/berichten/views/bericht_detail.py b/src/open_inwoner/berichten/views/bericht_detail.py index 715ace9b31..ad85f693d2 100644 --- a/src/open_inwoner/berichten/views/bericht_detail.py +++ b/src/open_inwoner/berichten/views/bericht_detail.py @@ -21,7 +21,7 @@ class BerichtDetailView(CommonPageMixin, BaseBreadcrumbMixin, TemplateView): def crumbs(self): return [ (_("Mijn berichten"), reverse("berichten:list")), - (_("Overzicht"), reverse("berichten:detail", kwargs=self.kwargs)), + (_("Bericht"), reverse("berichten:detail", kwargs=self.kwargs)), ] def page_title(self): diff --git a/src/open_inwoner/templates/pages/berichten/detail.html b/src/open_inwoner/templates/pages/berichten/detail.html index 1ef317485e..70477e2d7d 100644 --- a/src/open_inwoner/templates/pages/berichten/detail.html +++ b/src/open_inwoner/templates/pages/berichten/detail.html @@ -85,7 +85,7 @@

Bijlagen

- +
@@ -94,7 +94,7 @@

Bijlagen

{{ bericht.publicatiedatum }}
- +
From 4c6f3fb27d9383fcc1506b65d245de21f7b4fb65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cjiromaykin=E2=80=9D?= Date: Thu, 10 Oct 2024 00:17:17 +0200 Subject: [PATCH 6/9] [#2799] Cleaned-up code and margins --- .../components/Berichten/BerichtDetail.scss | 22 ++++ .../components/Berichten/BerichtenList.scss | 17 ++- .../templates/pages/berichten/detail.html | 36 +++--- .../templates/pages/berichten/list.html | 108 +++++++++--------- 4 files changed, 109 insertions(+), 74 deletions(-) diff --git a/src/open_inwoner/scss/components/Berichten/BerichtDetail.scss b/src/open_inwoner/scss/components/Berichten/BerichtDetail.scss index 6e6d86182f..eaa2a30639 100644 --- a/src/open_inwoner/scss/components/Berichten/BerichtDetail.scss +++ b/src/open_inwoner/scss/components/Berichten/BerichtDetail.scss @@ -10,6 +10,16 @@ margin-left: var(--spacing-medium); padding: var(--spacing-small) var(--spacing-medium); } + + .handelingstermijn { + display: flex; + flex-direction: row; + flex-wrap: wrap; + align-items: flex-end; + align-content: baseline; + justify-items: baseline; + justify-content: space-between; + } } &__heading { @@ -33,7 +43,19 @@ font-weight: bold; } + .utrecht-heading-2 { + margin-top: var(--spacing-large); + } + .button--transparent { padding: var(--spacing-medium) 0 0 0; } + + &__bijlagen { + .file__name { + // Reverse ellipsis: only show last part of URL + direction: rtl; + text-align: left; + } + } } diff --git a/src/open_inwoner/scss/components/Berichten/BerichtenList.scss b/src/open_inwoner/scss/components/Berichten/BerichtenList.scss index d8137dc966..ef46b8862c 100644 --- a/src/open_inwoner/scss/components/Berichten/BerichtenList.scss +++ b/src/open_inwoner/scss/components/Berichten/BerichtenList.scss @@ -16,14 +16,27 @@ text-align: center; } } - &.nohover:hover { - text-decoration: none !important; + &.nohover { + width: 100%; + justify-content: space-between; + + &:hover { + text-decoration: none !important; + } + + .button { + padding-right: 0; + } } } &__table { display: grid; + .table { + border-collapse: separate; + } + &-row:hover th, &-row:hover td { background-color: var(--color-gray-lightest); diff --git a/src/open_inwoner/templates/pages/berichten/detail.html b/src/open_inwoner/templates/pages/berichten/detail.html index 70477e2d7d..a4e67d0877 100644 --- a/src/open_inwoner/templates/pages/berichten/detail.html +++ b/src/open_inwoner/templates/pages/berichten/detail.html @@ -17,9 +17,15 @@

{{ bericht.onderwerp }}

Bericht type: {{ bericht.bericht_type }}

  • -

    - {% if bericht.einddatum_handelingstermijn %}{% endif %} - Deadline: {{ bericht.einddatum_handelingstermijn }} +

    + {# Icon only if deadline exists #} + {% if bericht.einddatum_handelingstermijn %} + {% icon icon="warning_amber" icon_position="after" extra_classes="icon--danger" outlined=True %} + {% endif %} + + Einddatum: + + {{ bericht.einddatum_handelingstermijn }}

  • @@ -30,12 +36,14 @@

    {{ bericht.onderwerp }}

    {% render_grid %} {% render_column start=4 span=6 %} + + {# Handeling #}
    -

    Actie

    +

    Actie

    {% if bericht.handelingsperspectief %} {{ bericht.handelingsperspectief }} @@ -44,7 +52,7 @@

    Actie

    {% endif %}

    - + {% icon "east" %}
    @@ -54,22 +62,15 @@

    Actie

    +

    {{ bericht.onderwerp }}

    {{ bericht.bericht_tekst|linebreaks }}

    - - {% if destination %} - - {% endif %}
    {% if bericht.bijlages %} @@ -85,17 +86,14 @@

    Bijlagen

    - + {% icon "insert_drive_file" outlined=True %}
    - - {{ attachment }} - (PDF) - + {{ attachment }} (PDF) {{ bericht.publicatiedatum }}
    - + {% icon "download" outlined=True %}
    diff --git a/src/open_inwoner/templates/pages/berichten/list.html b/src/open_inwoner/templates/pages/berichten/list.html index 44b25c5880..d5075f0f5a 100644 --- a/src/open_inwoner/templates/pages/berichten/list.html +++ b/src/open_inwoner/templates/pages/berichten/list.html @@ -1,5 +1,5 @@ {% extends 'master.html' %} -{% load i18n button_tags card_tags map_tags utils icon_tags file_tags action_tags dropdown_tags anchor_menu_tags file_tags %} +{% load i18n button_tags card_tags utils icon_tags grid_tags %} {% block content %} @@ -9,61 +9,63 @@

    Welkom in uw berichtencentrum. Hier vindt u een overzicht van uw notificaties.

    -
    - - - - - - - - - - - {% if not berichten %} - {% trans "U heeft op dit moment nog geen berichten." %} - {% endif %} + {% render_grid %} + {% render_column start=0 span=10 %} +
    +
    OnderwerpEinddatumStatusBericht type
    + + + + + + + + + + {% if not berichten %} + {% trans "U heeft op dit moment nog geen berichten." %} + {% endif %} - {% for bericht in berichten %} - - - - - + + + + - - {% endfor %} + + {% icon "arrow_forward" %} + + + + + {% endfor %} - -
    OnderwerpEinddatumStatusBericht type
    - - {{ bericht.onderwerp }} - - - - {{ bericht.publicatiedatum }} - - {% if bericht.geopend %} -
    - Geopend -
    - {% else %} -
    - Niet geopend -
    - {% endif %} -
    -
    - - {{ bericht.bericht_type }} + {% for bericht in berichten %} +
    + + {{ bericht.onderwerp }} + + + + {{ bericht.publicatiedatum }} + + {% if bericht.geopend %} +
    + Geopend +
    + {% else %} +
    + Niet geopend +
    + {% endif %} +
    +
    + + {{ bericht.bericht_type }} - - - - -
    - - {# end service list#} -
    + + +
    + {% endrender_column %} + {% endrender_grid %}
    {% endblock %} From c7178827dfbb3ad928d907fddb8beabec616ea96 Mon Sep 17 00:00:00 2001 From: Sidney Richards Date: Wed, 9 Oct 2024 13:00:21 +0200 Subject: [PATCH 7/9] Update bericht opened status upon accessing detail page --- src/open_inwoner/berichten/services.py | 25 +++++++++++++++++++ .../berichten/views/bericht_detail.py | 6 ++++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/src/open_inwoner/berichten/services.py b/src/open_inwoner/berichten/services.py index f499147bc6..05c85c5392 100644 --- a/src/open_inwoner/berichten/services.py +++ b/src/open_inwoner/berichten/services.py @@ -1,3 +1,4 @@ +import datetime from typing import Literal from objectsapiclient.client import Client as ObjectenClient @@ -39,3 +40,27 @@ def fetch_bericht(self, uuid: str): obj = self.client.get_object(uuid) return Bericht.model_validate(obj.record["data"] | {"object_uuid": obj.uuid}) + + def update_object(self, uuid: str, updated_data: dict): + + # TODO: the PATCH method in the Objects API does not appear to work as + # expected. It validates the partial against the JSON Schema, so in this + # case you have to supply an object that is valid according to the + # schema. We thus have to do our own merging. + + # Also: we are usign the underlying API directly to avoid going back and + # forth between camel and snake case. + existing_obj = self.client.objects_api.retrieve("object", uuid=uuid) + existing_data = existing_obj["record"]["data"] + self.client.objects_api.partial_update( + "object", + { + "record": { + "startAt": datetime.date.today().isoformat(), + "data": existing_data | updated_data, + } + }, + uuid=uuid, + ) + # Refresh the object and build the Bericht model + return self.client.get_object(uuid) diff --git a/src/open_inwoner/berichten/views/bericht_detail.py b/src/open_inwoner/berichten/views/bericht_detail.py index ad85f693d2..76fdbe7289 100644 --- a/src/open_inwoner/berichten/views/bericht_detail.py +++ b/src/open_inwoner/berichten/views/bericht_detail.py @@ -30,5 +30,9 @@ def page_title(self): def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) service = BerichtenService() - context["bericht"] = service.fetch_bericht(self.kwargs["object_uuid"]) + bericht = service.fetch_bericht(self.kwargs["object_uuid"]) + context["bericht"] = bericht + if not bericht.geopend: + service.update_object(self.kwargs["object_uuid"], {"geopend": True}) + return context From e466df9617d10167d8af10491ab92832191b5014 Mon Sep 17 00:00:00 2001 From: Sidney Richards Date: Wed, 9 Oct 2024 17:10:40 +0200 Subject: [PATCH 8/9] Add a URL to mark a bericht as unread --- src/open_inwoner/berichten/urls.py | 9 ++++++--- src/open_inwoner/berichten/views/__init__.py | 4 ++-- src/open_inwoner/berichten/views/bericht_detail.py | 14 +++++++++++++- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/src/open_inwoner/berichten/urls.py b/src/open_inwoner/berichten/urls.py index 280c696d46..03db5df0d3 100644 --- a/src/open_inwoner/berichten/urls.py +++ b/src/open_inwoner/berichten/urls.py @@ -1,12 +1,15 @@ from django.urls import path -from open_inwoner.berichten.views.bericht_detail import BerichtDetailView - -from .views import BerichtListView +from .views import BerichtDetailView, BerichtListView, mark_bericht_as_unread app_name = "berichten" urlpatterns = [ path("/", BerichtDetailView.as_view(), name="detail"), + path( + "/mark-unread", + mark_bericht_as_unread, + name="mark-bericht-unread", + ), path("", BerichtListView.as_view(), name="list"), ] diff --git a/src/open_inwoner/berichten/views/__init__.py b/src/open_inwoner/berichten/views/__init__.py index 46590ca808..e4eee06fe7 100644 --- a/src/open_inwoner/berichten/views/__init__.py +++ b/src/open_inwoner/berichten/views/__init__.py @@ -1,4 +1,4 @@ -from .bericht_detail import BerichtDetailView +from .bericht_detail import BerichtDetailView, mark_bericht_as_unread from .bericht_list import BerichtListView -__all__ = ["BerichtDetailView", "BerichtListView"] +__all__ = ["BerichtDetailView", "BerichtListView", "mark_bericht_as_unread"] diff --git a/src/open_inwoner/berichten/views/bericht_detail.py b/src/open_inwoner/berichten/views/bericht_detail.py index 76fdbe7289..329a8dac27 100644 --- a/src/open_inwoner/berichten/views/bericht_detail.py +++ b/src/open_inwoner/berichten/views/bericht_detail.py @@ -1,5 +1,8 @@ import logging +from django.contrib.auth.decorators import login_required +from django.contrib.auth.mixins import LoginRequiredMixin +from django.http import HttpResponseRedirect from django.urls import reverse from django.utils.functional import cached_property from django.utils.translation import gettext_lazy as _ @@ -13,7 +16,9 @@ logger = logging.getLogger(__name__) -class BerichtDetailView(CommonPageMixin, BaseBreadcrumbMixin, TemplateView): +class BerichtDetailView( + CommonPageMixin, BaseBreadcrumbMixin, TemplateView, LoginRequiredMixin +): template_name = "pages/berichten/detail.html" @@ -36,3 +41,10 @@ def get_context_data(self, **kwargs): service.update_object(self.kwargs["object_uuid"], {"geopend": True}) return context + + +@login_required +def mark_bericht_as_unread(request, object_uuid): + service = BerichtenService() + service.update_object(object_uuid, {"geopend": False}) + return HttpResponseRedirect(reverse("berichten:list")) From ade2fc37125eaacdeb4abc305492a6fb734f7f67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cjiromaykin=E2=80=9D?= Date: Tue, 8 Oct 2024 18:09:14 +0200 Subject: [PATCH 9/9] [#2799] Improved template for detailbericht + added menu items --- src/open_inwoner/scss/components/Berichten/BerichtenList.scss | 2 +- src/open_inwoner/templates/pages/berichten/detail.html | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/open_inwoner/scss/components/Berichten/BerichtenList.scss b/src/open_inwoner/scss/components/Berichten/BerichtenList.scss index ef46b8862c..621e40d63c 100644 --- a/src/open_inwoner/scss/components/Berichten/BerichtenList.scss +++ b/src/open_inwoner/scss/components/Berichten/BerichtenList.scss @@ -21,7 +21,7 @@ justify-content: space-between; &:hover { - text-decoration: none !important; + text-decoration: none; } .button { diff --git a/src/open_inwoner/templates/pages/berichten/detail.html b/src/open_inwoner/templates/pages/berichten/detail.html index a4e67d0877..570d1bf668 100644 --- a/src/open_inwoner/templates/pages/berichten/detail.html +++ b/src/open_inwoner/templates/pages/berichten/detail.html @@ -23,7 +23,7 @@

    {{ bericht.onderwerp }}

    {% icon icon="warning_amber" icon_position="after" extra_classes="icon--danger" outlined=True %} {% endif %} - Einddatum: + Einddatum: {{ bericht.einddatum_handelingstermijn }} @@ -36,7 +36,7 @@

    {{ bericht.onderwerp }}

    {% render_grid %} {% render_column start=4 span=6 %} - + {# Handeling #}