2017-08-13 13:44:48 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
|
|
|
from rest_framework import serializers
|
|
|
|
|
2017-08-16 22:33:02 +00:00
|
|
|
from core.models import (Child, DiaperChange, Feeding, Note, Sleep, Timer,
|
|
|
|
TummyTime)
|
2017-08-13 14:48:16 +00:00
|
|
|
|
|
|
|
|
2017-08-16 12:49:58 +00:00
|
|
|
class ChildSerializer(serializers.HyperlinkedModelSerializer):
|
2017-08-13 14:48:16 +00:00
|
|
|
class Meta:
|
2017-08-16 12:49:58 +00:00
|
|
|
model = Child
|
2017-08-13 14:48:16 +00:00
|
|
|
fields = ('first_name', 'last_name', 'birth_date')
|
|
|
|
|
|
|
|
|
2017-08-13 19:51:25 +00:00
|
|
|
class DiaperChangeSerializer(serializers.HyperlinkedModelSerializer):
|
2017-08-17 16:17:51 +00:00
|
|
|
child = serializers.HyperlinkedIdentityField(view_name='api:child-detail')
|
|
|
|
|
2017-08-13 19:51:25 +00:00
|
|
|
class Meta:
|
|
|
|
model = DiaperChange
|
2017-08-17 16:17:51 +00:00
|
|
|
fields = ('child', 'time', 'wet', 'solid', 'color')
|
2017-08-13 19:51:25 +00:00
|
|
|
|
|
|
|
|
2017-08-13 15:59:14 +00:00
|
|
|
class FeedingSerializer(serializers.HyperlinkedModelSerializer):
|
2017-08-17 16:17:51 +00:00
|
|
|
child = serializers.HyperlinkedIdentityField(view_name='api:child-detail')
|
|
|
|
|
2017-08-13 15:59:14 +00:00
|
|
|
class Meta:
|
|
|
|
model = Feeding
|
2017-08-17 16:17:51 +00:00
|
|
|
fields = ('child', 'start', 'end', 'duration', 'type', 'method',
|
2017-08-16 22:07:25 +00:00
|
|
|
'amount')
|
2017-08-13 15:59:14 +00:00
|
|
|
|
|
|
|
|
2017-08-13 20:48:16 +00:00
|
|
|
class NoteSerializer(serializers.HyperlinkedModelSerializer):
|
2017-08-17 16:17:51 +00:00
|
|
|
child = serializers.HyperlinkedIdentityField(view_name='api:child-detail')
|
|
|
|
|
2017-08-13 20:48:16 +00:00
|
|
|
class Meta:
|
|
|
|
model = Note
|
2017-08-17 16:17:51 +00:00
|
|
|
fields = ('child', 'note', 'time')
|
2017-08-13 20:48:16 +00:00
|
|
|
|
|
|
|
|
2017-08-13 14:48:16 +00:00
|
|
|
class SleepSerializer(serializers.HyperlinkedModelSerializer):
|
2017-08-17 16:17:51 +00:00
|
|
|
child = serializers.HyperlinkedIdentityField(view_name='api:child-detail')
|
|
|
|
|
2017-08-13 14:48:16 +00:00
|
|
|
class Meta:
|
|
|
|
model = Sleep
|
2017-08-17 16:17:51 +00:00
|
|
|
fields = ('child', 'start', 'end', 'duration')
|
2017-08-13 15:59:14 +00:00
|
|
|
|
|
|
|
|
2017-08-16 22:33:02 +00:00
|
|
|
class TimerSerializer(serializers.HyperlinkedModelSerializer):
|
|
|
|
class Meta:
|
|
|
|
model = Timer
|
2017-08-17 18:42:44 +00:00
|
|
|
fields = ('name', 'start', 'end', 'duration', 'active', 'user')
|
2017-08-16 22:33:02 +00:00
|
|
|
|
|
|
|
|
2017-08-13 19:05:44 +00:00
|
|
|
class TummyTimeSerializer(serializers.HyperlinkedModelSerializer):
|
2017-08-17 16:17:51 +00:00
|
|
|
child = serializers.HyperlinkedIdentityField(view_name='api:child-detail')
|
|
|
|
|
2017-08-13 19:05:44 +00:00
|
|
|
class Meta:
|
|
|
|
model = TummyTime
|
2017-08-17 16:17:51 +00:00
|
|
|
fields = ('child', 'start', 'end', 'duration', 'milestone')
|