events: save event to test notification transport
closes #3485 Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
251ab71c3a
commit
c3c8cbf7ef
|
@ -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(
|
||||||
|
|
Reference in New Issue