Skip to content

Commit

Permalink
✨ [#214] added expand to digitaal adress serializer
Browse files Browse the repository at this point in the history
  • Loading branch information
bart-maykin committed Aug 8, 2024
1 parent 81f16aa commit 3ec3d3f
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ class PartijAdmin(admin.ModelAdmin):
"fields": [
"uuid",
"voorkeurs_digitaal_adres",
"voorkeurs_rekeningnummer",
"nummer",
"interne_notitie",
"soort_partij",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

from rest_framework import serializers

from openklant.components.klantinteracties.api.serializers.constants import (
SERIALIZER_PATH,
)
from openklant.components.klantinteracties.api.validators import digitaal_adres_exists
from openklant.components.klantinteracties.models.digitaal_adres import DigitaalAdres
from openklant.components.klantinteracties.models.klantcontacten import Betrokkene
Expand Down Expand Up @@ -53,6 +56,16 @@ class DigitaalAdresSerializer(serializers.HyperlinkedModelSerializer):
source="betrokkene",
)

inclusion_serializers = {
# 1 level
"verstrekt_door_betrokkene": f"{SERIALIZER_PATH}.klantcontacten.BetrokkeneSerializer",
# 2 levels
"verstrekt_door_betrokkene.had_klantcontact": f"{SERIALIZER_PATH}.klantcontacten.KlantcontactSerializer",
# 3 levels
"verstrekt_door_betrokkene.had_klantcontact.leidde_tot_interne_taken": f"{SERIALIZER_PATH}"
".internetaken.InterneTaakSerializer",
}

class Meta:
model = DigitaalAdres
fields = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from openklant.components.klantinteracties.models.digitaal_adres import DigitaalAdres
from openklant.components.token.authentication import TokenAuthentication
from openklant.components.token.permission import TokenPermissions
from openklant.components.utils.mixins import ExpandMixin


@extend_schema(tags=["digitale adressen"])
Expand Down Expand Up @@ -37,7 +38,7 @@
description="Verwijder een digitaal adres.",
),
)
class DigitaalAdresViewSet(viewsets.ModelViewSet):
class DigitaalAdresViewSet(ExpandMixin, viewsets.ModelViewSet):
"""
Digitaal adres dat een betrokkene bij klantcontact verstrekte
voor gebruik bij opvolging van een klantcontact.
Expand Down
43 changes: 41 additions & 2 deletions src/openklant/components/klantinteracties/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1080,7 +1080,7 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/PaginatedDigitaalAdresList'
$ref: '#/components/schemas/PaginatedExpandDigitaalAdresList'
description: ''
post:
operationId: digitaleadressenCreate
Expand Down Expand Up @@ -1125,7 +1125,7 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/DigitaalAdres'
$ref: '#/components/schemas/ExpandDigitaalAdres'
description: ''
put:
operationId: digitaleadressenUpdate
Expand Down Expand Up @@ -3221,6 +3221,22 @@ components:
required:
- url
- uuid
ExpandDigitaalAdres:
allOf:
- $ref: '#/components/schemas/DigitaalAdres'
- type: object
properties:
_expand:
type: object
description: Display details of the linked resources requested in the
`expand` parameter
properties:
verstrekt_door_betrokkene:
allOf:
- $ref: '#/components/schemas/Betrokkene'
nullable: true
description: Digitaal adres dat een betrokkene bij klantcontact verstrekte
voor gebruik bij opvolging van een klantcontact.
ExpandKlantcontact:
allOf:
- $ref: '#/components/schemas/Klantcontact'
Expand Down Expand Up @@ -3717,6 +3733,29 @@ components:
type: array
items:
$ref: '#/components/schemas/DigitaalAdres'
PaginatedExpandDigitaalAdresList:
type: object
required:
- count
- results
properties:
count:
type: integer
example: 123
next:
type: string
nullable: true
format: uri
example: http://api.example.org/accounts/?page=4
previous:
type: string
nullable: true
format: uri
example: http://api.example.org/accounts/?page=2
results:
type: array
items:
$ref: '#/components/schemas/ExpandDigitaalAdres'
PaginatedExpandKlantcontactList:
type: object
required:
Expand Down
1 change: 1 addition & 0 deletions src/openklant/conf/dev.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

os.environ.setdefault("RELEASE", "dev")
os.environ.setdefault("LOG_REQUESTS", "no")
os.environ.setdefault("DISABLE_2FA", "yes")

from .base import * # noqa isort:skip

Expand Down

0 comments on commit 3ec3d3f

Please sign in to comment.