2017-08-13 13:44:48 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
|
|
|
from rest_framework import viewsets
|
|
|
|
|
2017-08-16 22:33:02 +00:00
|
|
|
from core.models import (Child, DiaperChange, Feeding, Note, Sleep, Timer,
|
|
|
|
TummyTime)
|
|
|
|
|
2017-08-16 12:49:58 +00:00
|
|
|
from .serializers import (ChildSerializer, DiaperChangeSerializer,
|
2017-08-13 20:48:16 +00:00
|
|
|
FeedingSerializer, NoteSerializer, SleepSerializer,
|
2017-08-16 22:33:02 +00:00
|
|
|
TimerSerializer, TummyTimeSerializer,)
|
2017-08-13 14:48:16 +00:00
|
|
|
|
|
|
|
|
2017-08-16 12:49:58 +00:00
|
|
|
class ChildViewSet(viewsets.ModelViewSet):
|
|
|
|
queryset = Child.objects.all()
|
|
|
|
serializer_class = ChildSerializer
|
2017-08-18 12:08:23 +00:00
|
|
|
lookup_field = 'slug'
|
2017-11-02 10:05:12 +00:00
|
|
|
filter_fields = ('first_name', 'last_name', 'slug')
|
2017-08-13 20:15:57 +00:00
|
|
|
|
2017-08-13 14:48:16 +00:00
|
|
|
|
2017-08-13 19:51:25 +00:00
|
|
|
class DiaperChangeViewSet(viewsets.ModelViewSet):
|
|
|
|
queryset = DiaperChange.objects.all()
|
|
|
|
serializer_class = DiaperChangeSerializer
|
2017-11-02 10:05:12 +00:00
|
|
|
filter_fields = ('child', 'wet', 'solid', 'color')
|
2017-08-13 20:15:57 +00:00
|
|
|
|
2017-08-13 19:51:25 +00:00
|
|
|
|
2017-08-13 15:59:14 +00:00
|
|
|
class FeedingViewSet(viewsets.ModelViewSet):
|
|
|
|
queryset = Feeding.objects.all()
|
|
|
|
serializer_class = FeedingSerializer
|
2017-11-02 10:05:12 +00:00
|
|
|
filter_fields = ('child', 'type', 'method')
|
2017-08-13 20:15:57 +00:00
|
|
|
|
2017-08-13 15:59:14 +00:00
|
|
|
|
2017-08-13 20:48:16 +00:00
|
|
|
class NoteViewSet(viewsets.ModelViewSet):
|
|
|
|
queryset = Note.objects.all()
|
|
|
|
serializer_class = NoteSerializer
|
2017-11-02 10:05:12 +00:00
|
|
|
filter_fields = ('child',)
|
2017-08-13 20:48:16 +00:00
|
|
|
|
|
|
|
|
2017-08-13 14:48:16 +00:00
|
|
|
class SleepViewSet(viewsets.ModelViewSet):
|
|
|
|
queryset = Sleep.objects.all()
|
|
|
|
serializer_class = SleepSerializer
|
2017-11-02 10:05:12 +00:00
|
|
|
filter_fields = ('child',)
|
2017-08-13 20:15:57 +00:00
|
|
|
|
2017-08-13 15:59:14 +00:00
|
|
|
|
2017-08-16 22:33:02 +00:00
|
|
|
class TimerViewSet(viewsets.ModelViewSet):
|
|
|
|
queryset = Timer.objects.all()
|
|
|
|
serializer_class = TimerSerializer
|
2017-11-02 10:05:12 +00:00
|
|
|
filter_fields = ('active', 'user')
|
2017-08-16 22:33:02 +00:00
|
|
|
|
|
|
|
|
2017-08-13 19:05:44 +00:00
|
|
|
class TummyTimeViewSet(viewsets.ModelViewSet):
|
|
|
|
queryset = TummyTime.objects.all()
|
|
|
|
serializer_class = TummyTimeSerializer
|
2017-11-02 10:05:12 +00:00
|
|
|
filter_fields = ('child',)
|