From 56fc93a39d812265387276187c498d00d7303130 Mon Sep 17 00:00:00 2001 From: Hanne Moa Date: Tue, 14 May 2024 14:41:44 +0200 Subject: [PATCH] Move FilterPreviewSerializer to where it belongs --- src/argus/notificationprofile/V1/serializers.py | 5 +++++ src/argus/notificationprofile/V1/views.py | 2 +- src/argus/notificationprofile/primitive_serializers.py | 5 ----- src/argus/notificationprofile/serializers.py | 2 +- src/argus/notificationprofile/views.py | 2 -- 5 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/argus/notificationprofile/V1/serializers.py b/src/argus/notificationprofile/V1/serializers.py index 1edc6a97f..815ad7fde 100644 --- a/src/argus/notificationprofile/V1/serializers.py +++ b/src/argus/notificationprofile/V1/serializers.py @@ -10,6 +10,11 @@ from ..validators import validate_filter_string +class FilterPreviewSerializer(serializers.Serializer): + sourceSystemIds = serializers.ListField(child=serializers.IntegerField(min_value=1), allow_empty=True) + tags = serializers.ListField(child=serializers.CharField(min_length=3), allow_empty=True) + + class FilterBlobSerializerV1(serializers.Serializer): sourceSystemIds = serializers.ListField( child=serializers.IntegerField(min_value=1), diff --git a/src/argus/notificationprofile/V1/views.py b/src/argus/notificationprofile/V1/views.py index 18fa26b80..6b6b4d76b 100644 --- a/src/argus/notificationprofile/V1/views.py +++ b/src/argus/notificationprofile/V1/views.py @@ -12,10 +12,10 @@ from .serializers import ( FilterSerializerV1, FilterBlobSerializerV1, + FilterPreviewSerializer, ResponseNotificationProfileSerializerV1, RequestNotificationProfileSerializerV1, ) -from ..primitive_serializers import FilterPreviewSerializer class FilterViewSetV1(viewsets.ModelViewSet): diff --git a/src/argus/notificationprofile/primitive_serializers.py b/src/argus/notificationprofile/primitive_serializers.py index 9c5cccebf..6ab65cc57 100644 --- a/src/argus/notificationprofile/primitive_serializers.py +++ b/src/argus/notificationprofile/primitive_serializers.py @@ -4,8 +4,3 @@ class CustomMultipleChoiceField(serializers.MultipleChoiceField): def to_internal_value(self, value): return list(super().to_internal_value(value)) - - -class FilterPreviewSerializer(serializers.Serializer): - sourceSystemIds = serializers.ListField(child=serializers.IntegerField(min_value=1), allow_empty=True) - tags = serializers.ListField(child=serializers.CharField(min_length=3), allow_empty=True) diff --git a/src/argus/notificationprofile/serializers.py b/src/argus/notificationprofile/serializers.py index 2872e06b1..880591e42 100644 --- a/src/argus/notificationprofile/serializers.py +++ b/src/argus/notificationprofile/serializers.py @@ -2,7 +2,7 @@ from argus.incident.constants import INCIDENT_LEVELS from argus.incident.models import Event -from .primitive_serializers import CustomMultipleChoiceField, FilterPreviewSerializer +from .primitive_serializers import CustomMultipleChoiceField from .media import api_safely_get_medium_object from .models import DestinationConfig, Filter, Media, NotificationProfile, TimeRecurrence, Timeslot diff --git a/src/argus/notificationprofile/views.py b/src/argus/notificationprofile/views.py index a403648f9..9d6607e58 100644 --- a/src/argus/notificationprofile/views.py +++ b/src/argus/notificationprofile/views.py @@ -18,7 +18,6 @@ from argus.notificationprofile.media import api_safely_get_medium_object from argus.notificationprofile.media.base import NotificationMedium from .models import DestinationConfig, Filter, Media, NotificationProfile, Timeslot -from .primitive_serializers import FilterPreviewSerializer from .serializers import ( DuplicateDestinationSerializer, FilterSerializer, @@ -245,7 +244,6 @@ def destroy(self, request, *args, **kwargs): # TODO: change HTTP method to GET, and get query data from URL class FilterPreviewView(APIView): - @extend_schema(request=FilterPreviewSerializer, responses={"200": IncidentSerializer}) def post(self, request, format=None): """ POST a filter, get a list of filtered incidents back