events: make notifications filterable
This commit is contained in:
parent
2d2a404028
commit
f959212692
|
@ -39,6 +39,13 @@ class NotificationViewSet(
|
||||||
|
|
||||||
queryset = Notification.objects.all()
|
queryset = Notification.objects.all()
|
||||||
serializer_class = NotificationSerializer
|
serializer_class = NotificationSerializer
|
||||||
|
filterset_fields = [
|
||||||
|
"severity",
|
||||||
|
"body",
|
||||||
|
"created",
|
||||||
|
"event",
|
||||||
|
"seen",
|
||||||
|
]
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
if not self.request:
|
if not self.request:
|
||||||
|
|
|
@ -8,7 +8,7 @@ from django.db.models.signals import post_save, pre_delete
|
||||||
from django.http import HttpRequest, HttpResponse
|
from django.http import HttpRequest, HttpResponse
|
||||||
|
|
||||||
from authentik.core.middleware import LOCAL
|
from authentik.core.middleware import LOCAL
|
||||||
from authentik.events.models import Event, EventAction
|
from authentik.events.models import Event, EventAction, Notification
|
||||||
from authentik.events.signals import EventNewThread
|
from authentik.events.signals import EventNewThread
|
||||||
from authentik.events.utils import model_to_dict
|
from authentik.events.utils import model_to_dict
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ class AuditMiddleware:
|
||||||
user: User, request: HttpRequest, sender, instance: Model, created: bool, **_
|
user: User, request: HttpRequest, sender, instance: Model, created: bool, **_
|
||||||
):
|
):
|
||||||
"""Signal handler for all object's post_save"""
|
"""Signal handler for all object's post_save"""
|
||||||
if isinstance(instance, Event):
|
if isinstance(instance, (Event, Notification)):
|
||||||
return
|
return
|
||||||
|
|
||||||
action = EventAction.MODEL_CREATED if created else EventAction.MODEL_UPDATED
|
action = EventAction.MODEL_CREATED if created else EventAction.MODEL_UPDATED
|
||||||
|
@ -75,7 +75,7 @@ class AuditMiddleware:
|
||||||
user: User, request: HttpRequest, sender, instance: Model, **_
|
user: User, request: HttpRequest, sender, instance: Model, **_
|
||||||
):
|
):
|
||||||
"""Signal handler for all object's pre_delete"""
|
"""Signal handler for all object's pre_delete"""
|
||||||
if isinstance(instance, Event):
|
if isinstance(instance, (Event, Notification)):
|
||||||
return
|
return
|
||||||
|
|
||||||
EventNewThread(
|
EventNewThread(
|
||||||
|
|
25
swagger.yaml
25
swagger.yaml
|
@ -984,6 +984,31 @@ paths:
|
||||||
operationId: events_notifications_list
|
operationId: events_notifications_list
|
||||||
description: Notification Viewset
|
description: Notification Viewset
|
||||||
parameters:
|
parameters:
|
||||||
|
- name: severity
|
||||||
|
in: query
|
||||||
|
description: ''
|
||||||
|
required: false
|
||||||
|
type: string
|
||||||
|
- name: body
|
||||||
|
in: query
|
||||||
|
description: ''
|
||||||
|
required: false
|
||||||
|
type: string
|
||||||
|
- name: created
|
||||||
|
in: query
|
||||||
|
description: ''
|
||||||
|
required: false
|
||||||
|
type: string
|
||||||
|
- name: event
|
||||||
|
in: query
|
||||||
|
description: ''
|
||||||
|
required: false
|
||||||
|
type: string
|
||||||
|
- name: seen
|
||||||
|
in: query
|
||||||
|
description: ''
|
||||||
|
required: false
|
||||||
|
type: string
|
||||||
- name: ordering
|
- name: ordering
|
||||||
in: query
|
in: query
|
||||||
description: Which field to use when ordering the results.
|
description: Which field to use when ordering the results.
|
||||||
|
|
Reference in New Issue