Skip to content

Commit d810a8b

Browse files
authored
Merge pull request #696 from maykinmedia/issue/689-notif-docs-incorrect
add correct resource to notification docs
2 parents 5e4f6dc + 1b1900c commit d810a8b

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

src/notificaties.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ De architectuur van de notificaties staat beschreven op <a href="https://github.
2727
**Resources en acties**
2828

2929

30-
* <code>objectrecord</code>: create, update, destroy, create, update, destroy
30+
* <code>object</code>: create, update, destroy
3131

3232

src/objects/api/mixins.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from notifications_api_common.viewsets import (
44
NotificationCreateMixin,
55
NotificationDestroyMixin,
6+
NotificationMixinBase,
67
conditional_atomic,
78
)
89
from rest_framework.exceptions import NotAcceptable
@@ -40,7 +41,22 @@ def perform_crs_negotation(self, request):
4041
raise NotAcceptable(detail=f"CRS '{requested_crs}' is niet ondersteund")
4142

4243

43-
class ObjectNotificationMixin(NotificationCreateMixin, NotificationDestroyMixin):
44+
class ObjectNotificationMixinBase(NotificationMixinBase):
45+
def __new__(cls, name, bases, attrs):
46+
new_cls = super().__new__(cls, name, bases, attrs)
47+
48+
if name == "ObjectViewSet":
49+
kanaal = attrs.get("notifications_kanaal")
50+
kanaal.usage["object"] = kanaal.usage.pop("objectrecord")
51+
52+
return new_cls
53+
54+
55+
class ObjectNotificationMixin(
56+
NotificationCreateMixin,
57+
NotificationDestroyMixin,
58+
metaclass=ObjectNotificationMixinBase,
59+
):
4460
def construct_message(self, data: dict, instance: models.Model = None) -> dict:
4561
message = super().construct_message(data, instance)
4662
message["resource"] = "object"

0 commit comments

Comments
 (0)