Viewsets

Settings to control the behavior of this library.

class notifications_api_common.viewsets.NotificationCreateMixin
create(request, *args, **kwargs)
class notifications_api_common.viewsets.NotificationDestroyMixin
destroy(request, *args, **kwargs)
class notifications_api_common.viewsets.NotificationMixin
construct_message(data: dict, instance: Model | None = None, kanaal=None, model=None, action=None) dict

Construct the message to send to the notification component.

Using the response data from the view/action, we introspect this data to send the appropriate response. By convention, every resource includes its own absolute url in the ‘url’ key - we can use this to look up the object it points to. By convention, relations use the name of the resource, so for sub-resources we can use this to get a reference back to the main resource.

get_kanaal() Kanaal
get_main_resource_key(kanaal: Kanaal) str

Determine the key in the (response) data that represents the main resource.

get_notification_main_object_url(data: dict, kanaal: Kanaal) str

Retrieve the URL for the main object.

notifications_kanaal: Kanaal | None = None
notifications_main_resource_key: str | None = None
notifications_wrap_in_atomic_block: bool = True
notify(status_code: int, data: List | Dict, instance: Model | None = None) None
class notifications_api_common.viewsets.NotificationMixinBase(name, bases, attrs)
class notifications_api_common.viewsets.NotificationUpdateMixin
update(request, *args, **kwargs)
class notifications_api_common.viewsets.NotificationViewSetMixin
class notifications_api_common.viewsets.ViewSetProtocol(*args, **kwargs)
action: str
destroy(request, *args, **kwargs) Any
get_kanaal() Kanaal
get_notification_main_object_url(data: dict, kanaal: Kanaal) str
get_object() Model
get_queryset() QuerySet
get_serializer(*args, **kwargs) Any
notifications_wrap_in_atomic_block: bool
notify(status_code: int, data: List | Dict, instance: Model | None = None) None
request: Any
notifications_api_common.viewsets.conditional_atomic(wrap: bool = True) Callable[[], ContextManager[None]]

Wrap either a fake or real atomic transaction context manager.