55 lines
1.4 KiB
Python
55 lines
1.4 KiB
Python
from rest_framework import serializers
|
|
|
|
from collection import models
|
|
from location import models as location_models
|
|
|
|
|
|
class CollectionSerializer(serializers.ModelSerializer):
|
|
"""Collection serializer"""
|
|
# RESPONSE
|
|
description_translated = serializers.CharField(read_only=True, allow_null=True)
|
|
|
|
# COMMON
|
|
block_size = serializers.JSONField()
|
|
is_publish = serializers.BooleanField()
|
|
on_top = serializers.BooleanField()
|
|
slug = serializers.SlugField(allow_blank=False, required=True, max_length=50)
|
|
|
|
# REQUEST
|
|
start = serializers.DateTimeField(write_only=True)
|
|
end = serializers.DateTimeField(write_only=True)
|
|
country = serializers.PrimaryKeyRelatedField(
|
|
queryset=location_models.Country.objects.all(),
|
|
write_only=True)
|
|
|
|
class Meta:
|
|
model = models.Collection
|
|
fields = [
|
|
'id',
|
|
'name',
|
|
'description_translated',
|
|
'start',
|
|
'end',
|
|
'image_url',
|
|
'is_publish',
|
|
'on_top',
|
|
'country',
|
|
'block_size',
|
|
'slug',
|
|
]
|
|
|
|
|
|
class GuideSerializer(serializers.ModelSerializer):
|
|
"""Guide serializer"""
|
|
class Meta:
|
|
model = models.Guide
|
|
fields = [
|
|
'id',
|
|
'name',
|
|
'start',
|
|
'end',
|
|
'parent',
|
|
'advertorials',
|
|
'collection'
|
|
]
|