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

Mijn Berichten demo (VNG Hackathon 2024) #1442

Draft
wants to merge 44 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
5a732e5
[#2798] Updated attempt at MijnTaken / TasksPlugin for OIP
alextreme Oct 6, 2024
29126f7
[#2798] Flake8 cleanup
alextreme Oct 6, 2024
1df2ce8
Setup basic Mijn Berichten urls and views
swrichards Oct 7, 2024
8c38c70
Add a mock Bericht object and model
swrichards Oct 7, 2024
4b4b752
[#2799] First set-up for front-end services-berichten
jiromaykin Oct 7, 2024
4116f90
[#2798] Only showing block if there are tasks
alextreme Oct 7, 2024
7a1eefc
Merge pull request #1425 from maykinmedia/swr/mijn-services-hackathon…
swrichards Oct 8, 2024
243695e
[#2799] Rebase
jiromaykin Oct 7, 2024
6f2239a
[#2799] First version of some styling for berichtenlist and detail
jiromaykin Oct 8, 2024
6cab617
[#2799] iSorted
jiromaykin Oct 8, 2024
56c9a16
Merge pull request #1426 from maykinmedia/feature/2799-frontend-mijnb…
swrichards Oct 8, 2024
22f3abe
Add objects-api-client-django pinned to Hackathon branch
swrichards Oct 8, 2024
61abd02
Connect Berichten views to Objects API
swrichards Oct 8, 2024
7179da6
Merge pull request #1424 from maykinmedia/issue/2798-tasks-cms-plugin…
alextreme Oct 8, 2024
e7e91b5
[#2798] Only show open tasks
alextreme Oct 8, 2024
7b6c2a1
Add objects-api-client-django pinned to Hackathon branch
swrichards Oct 8, 2024
3af2ab8
Connect Berichten views to Objects API
swrichards Oct 8, 2024
663fe21
Merge pull request #1429 from maykinmedia/swr/hackathon-fetch-objects
swrichards Oct 8, 2024
6117076
Merge pull request #1430 from maykinmedia/issue/mijn-taken-filter-on-…
alextreme Oct 8, 2024
2c52058
Update bericht opened status upon accessing detail page
swrichards Oct 9, 2024
5b7c7da
Add a URL to mark a bericht as unread
swrichards Oct 9, 2024
a6bd263
[#2799] Improved template for detailbericht + added menu items
jiromaykin Oct 8, 2024
d0826c2
Merge branch 'mijn-services-hackathon-2024' into issue/2799-design-mi…
jiromaykin Oct 9, 2024
0f97264
Merge pull request #1433 from maykinmedia/swr/hackathon-update-berich…
alextreme Oct 9, 2024
df3bdce
[#2799] Improved list template
jiromaykin Oct 9, 2024
a426754
[#2799] Improved template for detailbericht + added menu items
jiromaykin Oct 8, 2024
9db01c0
[#2799] Adjusted breadcrumb
jiromaykin Oct 9, 2024
dbfc2e3
Merge pull request #1432 from maykinmedia/issue/2799-design-mijnberic…
swrichards Oct 9, 2024
4c6f3fb
[#2799] Cleaned-up code and margins
jiromaykin Oct 9, 2024
c717882
Update bericht opened status upon accessing detail page
swrichards Oct 9, 2024
e466df9
Add a URL to mark a bericht as unread
swrichards Oct 9, 2024
ade2fc3
[#2799] Improved template for detailbericht + added menu items
jiromaykin Oct 8, 2024
f4b3beb
Merge branch 'mijn-services-hackathon-2024' into issue/2799-final-hac…
jiromaykin Oct 10, 2024
5cb9706
Merge pull request #1434 from maykinmedia/issue/2799-final-hackathon-…
swrichards Oct 10, 2024
5989412
Fix serialization of bericht dates to Javascript code
swrichards Oct 10, 2024
a30eab2
Add mark unread button to Bericht detail
swrichards Oct 10, 2024
f3c5134
Update Mijn Berichten link with template tag
swrichards Oct 10, 2024
ea0e446
Remove handeling block from Bericht detail
swrichards Oct 10, 2024
f04cecf
Merge pull request #1435 from maykinmedia/swr/hackathon-ui-tweaks
alextreme Oct 10, 2024
91c82fb
Improved acess checks for Bericht views
swrichards Oct 10, 2024
707ecf5
Add bericht download functionality
swrichards Oct 11, 2024
9072cdd
Better UI logic for handling missing einddatum handelingstermijn
swrichards Oct 11, 2024
cedfcdb
Merge pull request #1436 from maykinmedia/swr/better-access-checks
alextreme Oct 11, 2024
d289785
Merge pull request #1437 from maykinmedia/swr/download-bericht-attach…
alextreme Oct 14, 2024
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
1 change: 1 addition & 0 deletions requirements/base.in
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ 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
Expand Down
16 changes: 10 additions & 6 deletions requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ asgiref==3.7.2
# via django
asn1crypto==1.5.1
# via webauthn
async-timeout==4.0.3
# via redis
attrs==21.2.0
# via
# glom
Expand Down Expand Up @@ -146,6 +148,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
Expand Down Expand Up @@ -272,6 +275,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
Expand Down Expand Up @@ -340,9 +344,7 @@ faker==27.0.0
fontawesomefree==6.4.2
# via -r requirements/base.in
fonttools[woff]==4.43.0
# via
# fonttools
# weasyprint
# via weasyprint
furl==2.1.3
# via
# -r requirements/base.in
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -532,9 +537,7 @@ sqlparse==0.4.4
svglib==1.5.1
# via easy-thumbnails
tablib[html,ods,xls,xlsx,yaml]==3.1.0
# via
# django-import-export
# tablib
# via django-import-export
tinycss2==1.1.1
# via
# -r requirements/base.in
Expand Down Expand Up @@ -594,6 +597,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
Expand Down
18 changes: 13 additions & 5 deletions requirements/ci.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ asn1crypto==1.5.1
# webauthn
astroid==2.15.8
# via pylint
async-timeout==4.0.3
# via
# -c requirements/base.txt
# -r requirements/base.txt
# redis
attrs==21.2.0
# via
# -c requirements/base.txt
Expand Down Expand Up @@ -238,6 +243,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
Expand Down Expand Up @@ -460,6 +466,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
Expand All @@ -480,7 +487,6 @@ django-two-factor-auth[phonenumberslite,webauthn]==1.16.0
# via
# -c requirements/base.txt
# -r requirements/base.txt
# django-two-factor-auth
# maykin-2fa
django-view-breadcrumbs==2.5.1
# via
Expand Down Expand Up @@ -553,7 +559,6 @@ easy-thumbnails[svg]==2.8.5
# -r requirements/base.txt
# django-filer
# djangocms-picture
# easy-thumbnails
ecs-logging==2.1.0
# via
# -c requirements/base.txt
Expand Down Expand Up @@ -607,7 +612,6 @@ fonttools[woff]==4.43.0
# via
# -c requirements/base.txt
# -r requirements/base.txt
# fonttools
# weasyprint
freezegun==1.1.0
# via -r requirements/test-tools.in
Expand Down Expand Up @@ -764,6 +768,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
Expand Down Expand Up @@ -839,7 +847,6 @@ pydantic[email]==2.6.4
# via
# -c requirements/base.txt
# -r requirements/base.txt
# pydantic
pydantic-core==2.16.3
# via
# -c requirements/base.txt
Expand Down Expand Up @@ -973,6 +980,7 @@ requests==2.31.0
# maykin-python3-saml
# messagebird
# mozilla-django-oidc
# objects-api-client-django
# requests-mock
# sphinx
# zgw-consumers
Expand Down Expand Up @@ -1050,7 +1058,6 @@ tablib[html,ods,xls,xlsx,yaml]==3.1.0
# -c requirements/base.txt
# -r requirements/base.txt
# django-import-export
# tablib
tblib==1.7.0
# via -r requirements/test-tools.in
tinycss2==1.1.1
Expand Down Expand Up @@ -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
Expand Down
18 changes: 13 additions & 5 deletions requirements/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ astroid==2.15.8
# -c requirements/ci.txt
# -r requirements/ci.txt
# pylint
async-timeout==4.0.3
# via
# -c requirements/ci.txt
# -r requirements/ci.txt
# redis
attrs==21.2.0
# via
# -c requirements/ci.txt
Expand Down Expand Up @@ -278,6 +283,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
Expand Down Expand Up @@ -506,6 +512,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
Expand All @@ -526,7 +533,6 @@ django-two-factor-auth[phonenumberslite,webauthn]==1.16.0
# via
# -c requirements/ci.txt
# -r requirements/ci.txt
# django-two-factor-auth
# maykin-2fa
django-view-breadcrumbs==2.5.1
# via
Expand Down Expand Up @@ -603,7 +609,6 @@ easy-thumbnails[svg]==2.8.5
# -r requirements/ci.txt
# django-filer
# djangocms-picture
# easy-thumbnails
ecs-logging==2.1.0
# via
# -c requirements/ci.txt
Expand Down Expand Up @@ -670,7 +675,6 @@ fonttools[woff]==4.43.0
# via
# -c requirements/ci.txt
# -r requirements/ci.txt
# fonttools
# weasyprint
freezegun==1.1.0
# via
Expand Down Expand Up @@ -874,6 +878,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
Expand Down Expand Up @@ -974,7 +982,6 @@ pydantic[email]==2.6.4
# via
# -c requirements/ci.txt
# -r requirements/ci.txt
# pydantic
pydantic-core==2.16.3
# via
# -c requirements/ci.txt
Expand Down Expand Up @@ -1125,6 +1132,7 @@ requests==2.31.0
# maykin-python3-saml
# messagebird
# mozilla-django-oidc
# objects-api-client-django
# requests-mock
# sphinx
# zgw-consumers
Expand Down Expand Up @@ -1244,7 +1252,6 @@ tablib[html,ods,xls,xlsx,yaml]==3.1.0
# -c requirements/ci.txt
# -r requirements/ci.txt
# django-import-export
# tablib
tblib==1.7.0
# via
# -c requirements/ci.txt
Expand Down Expand Up @@ -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
Expand Down
Empty file.
50 changes: 50 additions & 0 deletions src/open_inwoner/berichten/api_models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# generated by datamodel-codegen:
# filename: bericht.json
# timestamp: 2024-10-07T14:27:37+00:00

from __future__ import annotations

from datetime import date
from typing import List, Optional

from pydantic import BaseModel, Field, constr
from typing_extensions import Literal


class Identificatie(BaseModel):
type: Literal["bsn", "kvk"] = "bsn"
value: Optional[constr(pattern=r"^[0-9]+$")] = None # noqa: F722


class Bericht(BaseModel):
object_uuid: str = Field(..., description="UUID van het onderliggende object")
onderwerp: str = Field(..., description="Onderwerp van het bericht")
bericht_tekst: str = Field(
...,
description="Tekst van het bericht. Mag URL bevatten en /r/n voor newline. Geen verdere opmaak mogelijk.",
)
publicatiedatum: date = Field(
...,
description="Tijdstip van verwerken van het bericht of de PublicatieDatum indien deze is ingevuld",
)
einddatum_handelingstermijn: Optional[date] = Field(
None, description="Termijn waarbinnen de geadresseerde moet reageren"
)
referentie: Optional[str] = Field(None, description="TODO")
handelingsperspectief: Optional[
Literal["betalen", "informatie verstrekken", "informatie ontvangen", "TODO"]
] = Field(None, description="TODO: Benodigde reactie van de geadresseerde")
geopend: bool = Field(
...,
description="Het bericht is door de geadresseerde geopend of nog niet geopend",
)
bericht_type: Literal[
"notificatie", "betaalverzoek", "uitnodiging", "verzoek", "TODO"
] = Field(..., description="Type bericht")
identificatie: Identificatie = Field(..., description="TODO")
# TODO: Should be AnyUrl
bijlages: List[str] = Field(
...,
description="TODO",
examples=[["https://documenten.nl/api/v1/enkelvoudiginformatieobjecten/1"]],
)
66 changes: 66 additions & 0 deletions src/open_inwoner/berichten/services.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import datetime
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})

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)
Loading
Loading