34 lines
1.0 KiB
Python
34 lines
1.0 KiB
Python
from rest_framework import serializers
|
|
from location.models import Country
|
|
from location.serializers import CountrySimpleSerializer
|
|
from collection.serializers.common import CollectionBaseSerializer
|
|
from collection import models
|
|
|
|
|
|
class CollectionBackOfficeSerializer(CollectionBaseSerializer):
|
|
"""Collection back serializer."""
|
|
country_id = serializers.PrimaryKeyRelatedField(
|
|
source='country', write_only=True,
|
|
queryset=Country.objects.all())
|
|
collection_type_display = serializers.CharField(
|
|
source='get_collection_type_display', read_only=True)
|
|
country = CountrySimpleSerializer(read_only=True)
|
|
|
|
class Meta:
|
|
model = models.Collection
|
|
fields = CollectionBaseSerializer.Meta.fields + [
|
|
'id',
|
|
'name',
|
|
'collection_type',
|
|
'collection_type_display',
|
|
'is_publish',
|
|
'on_top',
|
|
'country',
|
|
'country_id',
|
|
'block_size',
|
|
'description',
|
|
'slug',
|
|
'start',
|
|
'end',
|
|
]
|