summaryrefslogtreecommitdiffstats
path: root/storage/serializers.py
blob: f7f58a8265cf3206269a4acb1fc80beb9f241b75 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
from storage.models import Item, Label
from rest_framework import serializers
from rest_framework_hstore.serializers import HStoreSerializer


class ItemSerializer(HStoreSerializer):
    class Meta:
        model = Item
        fields = ('uuid', 'name', 'description', 'props', 'state', 'parent')

class LabelSerializer(serializers.ModelSerializer):
    item = ItemSerializer(required=False)
    item_id = serializers.PrimaryKeyRelatedField(queryset=Item.objects, source='item')
    class Meta:
        model = Label
        fields = ('id', 'item', 'item_id', 'style')