events: save event to test notification transport

closes #3485

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2022-08-28 15:39:42 +02:00
parent 251ab71c3a
commit c3c8cbf7ef
1 changed files with 8 additions and 6 deletions

View File

@ -85,16 +85,18 @@ class NotificationTransportViewSet(UsedByMixin, ModelViewSet):
"""Send example notification using selected transport. Requires """Send example notification using selected transport. Requires
Modify permissions.""" Modify permissions."""
transport: NotificationTransport = self.get_object() transport: NotificationTransport = self.get_object()
event = Event.new(
action="notification_test",
user=get_user(request.user),
app=self.__class__.__module__,
context={"foo": "bar"},
)
event.save()
notification = Notification( notification = Notification(
severity=NotificationSeverity.NOTICE, severity=NotificationSeverity.NOTICE,
body=f"Test Notification from transport {transport.name}", body=f"Test Notification from transport {transport.name}",
user=request.user, user=request.user,
event=Event( event=event,
action="Test",
user=get_user(request.user),
app=self.__class__.__module__,
context={"foo": "bar"},
),
) )
try: try:
response = NotificationTransportTestSerializer( response = NotificationTransportTestSerializer(