2023-05-20 16:47:08 +03:00
|
|
|
from rest_framework import serializers
|
|
|
|
|
2023-05-23 00:33:04 +03:00
|
|
|
from passfinder.events.models import Hotel, HotelPhone, City, Event, BasePoint, Region
|
2023-05-20 16:47:08 +03:00
|
|
|
|
|
|
|
|
|
|
|
class HotelPhoneSerializer(serializers.ModelSerializer):
|
|
|
|
class Meta:
|
|
|
|
model = HotelPhone
|
|
|
|
exclude = "hotel"
|
|
|
|
|
|
|
|
|
|
|
|
class CitySerializer(serializers.ModelSerializer):
|
|
|
|
class Meta:
|
|
|
|
model = City
|
|
|
|
|
|
|
|
|
|
|
|
class HotelSerializer(serializers.ModelSerializer):
|
|
|
|
phones = HotelPhoneSerializer(many=True)
|
|
|
|
source = serializers.CharField(source="parser_source")
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
model = Hotel
|
|
|
|
exclude = ("oid", "parser_source")
|
|
|
|
|
|
|
|
|
|
|
|
class MuseumSerializer(serializers.ModelSerializer):
|
|
|
|
phones = HotelPhoneSerializer(many=True)
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
model = Hotel
|
|
|
|
exclude = "oid"
|
2023-05-21 13:37:21 +03:00
|
|
|
|
|
|
|
|
|
|
|
class EventSerializer(serializers.ModelSerializer):
|
|
|
|
class Meta:
|
|
|
|
model = Event
|
2023-05-21 20:46:07 +03:00
|
|
|
fields = ("type", "title", "description", "city", "oid")
|
|
|
|
|
|
|
|
|
|
|
|
class PointSerializer(serializers.ModelSerializer):
|
|
|
|
class Meta:
|
|
|
|
model = BasePoint
|
|
|
|
fields = ["title", "description", "location", "icon"]
|
2023-05-22 22:29:46 +03:00
|
|
|
|
|
|
|
|
|
|
|
class RouteSerializer(serializers.Serializer):
|
|
|
|
name = serializers.CharField()
|
|
|
|
description = serializers.CharField()
|
|
|
|
points = serializers.ListSerializer(child=PointSerializer())
|
2023-05-23 00:33:04 +03:00
|
|
|
|
|
|
|
|
|
|
|
class RegionSerializer(serializers.ModelSerializer):
|
|
|
|
class Meta:
|
|
|
|
model = Region
|
|
|
|
fields = ["oid", "title", "description_short"]
|