backend/app/search/api/serializers.py

89 lines
2.5 KiB
Python
Raw Normal View History

2022-10-21 21:39:04 +03:00
from rest_framework import serializers
2022-10-22 03:09:14 +03:00
from django.core.validators import MinLengthValidator, MinValueValidator
2022-10-21 21:39:04 +03:00
2022-10-22 05:07:25 +03:00
class QueryFilterSerializer(serializers.Serializer):
value = serializers.CharField(max_length=100)
type = serializers.CharField(max_length=100)
def create(self, validated_data):
raise NotImplementedError
def update(self, instance, validated_data):
raise NotImplementedError
2022-10-21 21:39:04 +03:00
class SearchSerializer(serializers.Serializer):
2022-10-22 05:07:25 +03:00
body = serializers.ListSerializer(child=QueryFilterSerializer())
2022-10-22 11:43:30 +03:00
limit = serializers.IntegerField(default=5, min_value=1)
offset = serializers.IntegerField(default=0, min_value=0)
2022-10-21 21:39:04 +03:00
def create(self, validated_data):
raise NotImplementedError
2022-10-21 21:39:04 +03:00
def update(self, instance, validated_data):
raise NotImplementedError
2022-10-21 21:39:04 +03:00
class ResponseSerializer(serializers.Serializer):
results = serializers.JSONField()
def create(self, validated_data):
raise NotImplementedError
2022-10-21 21:39:04 +03:00
def update(self, instance, validated_data):
raise NotImplementedError
2022-10-21 23:22:14 +03:00
class HintRequestSerializer(serializers.Serializer):
content = serializers.CharField()
def create(self, validated_data):
2022-10-22 11:43:30 +03:00
raise NotImplementedError
def update(self, instance, validated_data):
raise NotImplementedError
2022-10-21 23:22:14 +03:00
class HintResponseSerializer(serializers.Serializer):
type = serializers.CharField()
content = serializers.CharField()
2022-10-22 03:09:14 +03:00
2022-10-22 11:43:30 +03:00
def create(self, validated_data):
raise NotImplementedError
def update(self, instance, validated_data):
raise NotImplementedError
2022-10-22 03:09:14 +03:00
class AutoCompleteRequestSerializer(serializers.Serializer):
content = serializers.CharField(validators=[MinLengthValidator(3)])
exclude = serializers.ListSerializer(child=QueryFilterSerializer(), default=[])
2022-10-22 03:09:14 +03:00
2022-10-22 11:43:30 +03:00
def create(self, validated_data):
raise NotImplementedError
def update(self, instance, validated_data):
raise NotImplementedError
2022-10-22 03:09:14 +03:00
class AutoCompleteSerializerNode(serializers.Serializer):
coordinate = serializers.IntegerField(validators=[MinValueValidator(0)])
value = HintResponseSerializer()
2022-10-22 11:43:30 +03:00
def create(self, validated_data):
raise NotImplementedError
def update(self, instance, validated_data):
raise NotImplementedError
2022-10-22 03:09:14 +03:00
class AutoCompleteResponseSerializer(serializers.Serializer):
nodes = serializers.ListField(child=AutoCompleteSerializerNode())
2022-10-22 11:43:30 +03:00
def create(self, validated_data):
raise NotImplementedError
def update(self, instance, validated_data):
raise NotImplementedError