Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion src/notificaties.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ De architectuur van de notificaties staat beschreven op <a href="https://github.
**Resources en acties**


* <code>objectrecord</code>: create, update, destroy, create, update, destroy
* <code>object</code>: create, update, destroy


18 changes: 17 additions & 1 deletion src/objects/api/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from notifications_api_common.viewsets import (
NotificationCreateMixin,
NotificationDestroyMixin,
NotificationMixinBase,
conditional_atomic,
)
from rest_framework.exceptions import NotAcceptable
Expand Down Expand Up @@ -40,7 +41,22 @@ def perform_crs_negotation(self, request):
raise NotAcceptable(detail=f"CRS '{requested_crs}' is niet ondersteund")


class ObjectNotificationMixin(NotificationCreateMixin, NotificationDestroyMixin):
class ObjectNotificationMixinBase(NotificationMixinBase):
def __new__(cls, name, bases, attrs):
new_cls = super().__new__(cls, name, bases, attrs)

if name == "ObjectViewSet":
kanaal = attrs.get("notifications_kanaal")
kanaal.usage["object"] = kanaal.usage.pop("objectrecord")

return new_cls


class ObjectNotificationMixin(
NotificationCreateMixin,
NotificationDestroyMixin,
metaclass=ObjectNotificationMixinBase,
):
def construct_message(self, data: dict, instance: models.Model = None) -> dict:
message = super().construct_message(data, instance)
message["resource"] = "object"
Expand Down
Loading