Skip to content

Commit

Permalink
Move FilterPreviewSerializer to where it belongs
Browse files Browse the repository at this point in the history
  • Loading branch information
hmpf committed May 15, 2024
1 parent e3b48bc commit 56fc93a
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 9 deletions.
5 changes: 5 additions & 0 deletions src/argus/notificationprofile/V1/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion src/argus/notificationprofile/V1/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
from .serializers import (
FilterSerializerV1,
FilterBlobSerializerV1,
FilterPreviewSerializer,
ResponseNotificationProfileSerializerV1,
RequestNotificationProfileSerializerV1,
)
from ..primitive_serializers import FilterPreviewSerializer


class FilterViewSetV1(viewsets.ModelViewSet):
Expand Down
5 changes: 0 additions & 5 deletions src/argus/notificationprofile/primitive_serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
2 changes: 1 addition & 1 deletion src/argus/notificationprofile/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 0 additions & 2 deletions src/argus/notificationprofile/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 56fc93a

Please sign in to comment.