Skip to content

Commit

Permalink
✨ [#207] Add experimental PUT and PATCH for Kanaal
Browse files Browse the repository at this point in the history
this is required to support new kenmerken on the zaken kanaal, because the Kanaal has to be updated in Open Notificaties for it to work
  • Loading branch information
stevenbal committed Dec 17, 2024
1 parent fa08b63 commit e7a40ed
Show file tree
Hide file tree
Showing 4 changed files with 392 additions and 5 deletions.
9 changes: 8 additions & 1 deletion src/nrc/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
from djangorestframework_camel_case.util import camelize, underscoreize
from notifications_api_common.api.serializers import NotificatieSerializer
from rest_framework import fields, serializers
from vng_api_common.validators import URLValidator
from rest_framework.validators import UniqueValidator
from vng_api_common.validators import IsImmutableValidator, URLValidator

from nrc.api.tasks import deliver_message
from nrc.datamodel.models import Abonnement, Filter, FilterGroup, Kanaal, Notificatie
Expand Down Expand Up @@ -39,6 +40,12 @@ class Meta:
fields = ("url", "naam", "documentatie_link", "filters")
extra_kwargs = {
"url": {"lookup_field": "uuid"},
"naam": {
"validators": [
UniqueValidator(queryset=Kanaal.objects.all()),
IsImmutableValidator(),
]
},
"documentatie_link": {"required": False, "validators": [URLValidator()]},
"filters": {"required": False},
}
Expand Down
10 changes: 9 additions & 1 deletion src/nrc/api/viewsets.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from vng_api_common.viewsets import CheckQueryParamsMixin

from nrc.datamodel.models import Abonnement, Kanaal
from nrc.utils.help_text import mark_experimental

from .filters import KanaalFilter
from .scopes import SCOPE_NOTIFICATIES_CONSUMEREN, SCOPE_NOTIFICATIES_PUBLICEREN
Expand Down Expand Up @@ -54,17 +55,22 @@ def perform_create(self, serializer):
@extend_schema_view(
list=extend_schema(summary="Alle KANAALen opvragen."),
retrieve=extend_schema(summary="Een specifiek KANAAL opvragen."),
update=extend_schema(summary=mark_experimental("Een specifiek KANAAL bewerken.")),
partial_update=extend_schema(
summary=mark_experimental("Een specifiek KANAAL deels bewerken.")
),
create=extend_schema(summary="Maak een KANAAL aan."),
)
class KanaalViewSet(
CheckQueryParamsMixin,
mixins.CreateModelMixin,
mixins.ListModelMixin,
mixins.UpdateModelMixin,
mixins.RetrieveModelMixin,
viewsets.GenericViewSet,
):
"""
Opvragen en aanmaken van KANAALen.
Opvragen, aanmaken en bewerken van KANAALen.
Op een KANAAL publiceren componenten (bronnen) hun NOTIFICATIEs. Alleen
componenten die NOTIFICATIEs willen publiceren dienen een KANAAL aan te
Expand All @@ -80,6 +86,8 @@ class KanaalViewSet(
"list": SCOPE_NOTIFICATIES_PUBLICEREN | SCOPE_NOTIFICATIES_CONSUMEREN,
"retrieve": SCOPE_NOTIFICATIES_PUBLICEREN | SCOPE_NOTIFICATIES_CONSUMEREN,
"create": SCOPE_NOTIFICATIES_PUBLICEREN,
"update": SCOPE_NOTIFICATIES_PUBLICEREN,
"partial_update": SCOPE_NOTIFICATIES_PUBLICEREN,
}


Expand Down
5 changes: 5 additions & 0 deletions src/nrc/utils/help_text.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django.utils.translation import gettext_lazy as _


def mark_experimental(text):
return _("**EXPERIMENTEEL** {}").format(text)
Loading

0 comments on commit e7a40ed

Please sign in to comment.