2017-04-28 12:14:27 +00:00
|
|
|
from storage.models import Item, Label
|
2017-03-06 15:50:55 +00:00
|
|
|
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')
|
2017-04-28 12:14:27 +00:00
|
|
|
|
|
|
|
class LabelSerializer(serializers.ModelSerializer):
|
2017-10-02 19:20:02 +00:00
|
|
|
item = ItemSerializer(required=False)
|
2017-09-05 23:23:04 +00:00
|
|
|
item_id = serializers.PrimaryKeyRelatedField(queryset=Item.objects, source='item')
|
2017-04-28 12:14:27 +00:00
|
|
|
class Meta:
|
|
|
|
model = Label
|
2017-09-05 23:23:04 +00:00
|
|
|
fields = ('id', 'item', 'item_id', 'style')
|