django-orchestra/orchestra/apps/websites/serializers.py

28 lines
913 B
Python
Raw Normal View History

2014-05-08 16:59:35 +00:00
from rest_framework import serializers
from orchestra.api.fields import OptionField
2014-10-15 21:18:50 +00:00
from orchestra.api.serializers import HyperlinkedModelSerializer
2014-05-08 16:59:35 +00:00
from orchestra.apps.accounts.serializers import AccountSerializerMixin
from .models import Website, Content
class ContentSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = Content
fields = ('webapp', 'path')
def get_identity(self, data):
return '%s-%s' % (data.get('website'), data.get('path'))
2014-05-08 16:59:35 +00:00
2014-10-15 21:18:50 +00:00
class WebsiteSerializer(AccountSerializerMixin, HyperlinkedModelSerializer):
2014-05-08 16:59:35 +00:00
contents = ContentSerializer(required=False, many=True, allow_add_remove=True,
source='content_set')
options = OptionField(required=False)
class Meta:
model = Website
fields = ('url', 'name', 'port', 'domains', 'is_active', 'contents', 'options')
2014-10-15 21:18:50 +00:00
postonly_fileds = ('name',)