mirror of
https://github.com/task-17-lct/backend.git
synced 2024-11-15 06:46:36 +03:00
56 lines
1.4 KiB
Python
56 lines
1.4 KiB
Python
from rest_framework import serializers
|
|
|
|
from passfinder.events.models import Hotel, HotelPhone, City, Event, BasePoint, Region
|
|
|
|
|
|
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"
|
|
|
|
|
|
class EventSerializer(serializers.ModelSerializer):
|
|
class Meta:
|
|
model = Event
|
|
fields = ("type", "title", "description", "city", "oid")
|
|
|
|
|
|
class PointSerializer(serializers.ModelSerializer):
|
|
class Meta:
|
|
model = BasePoint
|
|
fields = ["title", "description", "location", "icon"]
|
|
|
|
|
|
class RouteSerializer(serializers.Serializer):
|
|
name = serializers.CharField()
|
|
description = serializers.CharField()
|
|
points = serializers.ListSerializer(child=PointSerializer())
|
|
|
|
|
|
class RegionSerializer(serializers.ModelSerializer):
|
|
class Meta:
|
|
model = Region
|
|
fields = ["oid", "title", "description_short"]
|