2017-08-15 19:14:03 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
2017-08-16 16:46:26 +00:00
|
|
|
from django.contrib.auth.mixins import LoginRequiredMixin
|
2017-08-15 19:14:03 +00:00
|
|
|
from django.views.generic.base import TemplateView
|
2017-08-15 20:24:55 +00:00
|
|
|
from django.views.generic.edit import CreateView, UpdateView, DeleteView
|
2017-08-16 13:12:49 +00:00
|
|
|
from django.views.generic.list import ListView
|
2017-08-15 19:14:03 +00:00
|
|
|
|
2017-08-16 15:16:27 +00:00
|
|
|
from .models import Child, DiaperChange, Feeding, Note, Sleep, TummyTime
|
2017-08-16 18:17:27 +00:00
|
|
|
from .forms import ChildAddForm
|
2017-08-15 19:14:03 +00:00
|
|
|
|
2017-08-15 20:24:55 +00:00
|
|
|
|
2017-08-16 16:46:26 +00:00
|
|
|
class Dashboard(LoginRequiredMixin, TemplateView):
|
2017-08-15 19:14:03 +00:00
|
|
|
template_name = 'core/index.html'
|
2017-08-15 20:24:55 +00:00
|
|
|
|
|
|
|
|
2017-08-16 16:46:26 +00:00
|
|
|
class ChildList(LoginRequiredMixin, ListView):
|
2017-08-16 13:12:49 +00:00
|
|
|
model = Child
|
|
|
|
|
|
|
|
|
2017-08-16 16:46:26 +00:00
|
|
|
class ChildAdd(LoginRequiredMixin, CreateView):
|
2017-08-16 18:17:27 +00:00
|
|
|
form_class = ChildAddForm
|
2017-08-16 12:49:58 +00:00
|
|
|
model = Child
|
2017-08-16 13:12:49 +00:00
|
|
|
success_url = '/children'
|
2017-08-15 20:24:55 +00:00
|
|
|
|
|
|
|
|
2017-08-16 16:46:26 +00:00
|
|
|
class ChildUpdate(LoginRequiredMixin, UpdateView):
|
2017-08-16 12:49:58 +00:00
|
|
|
model = Child
|
2017-08-15 20:24:55 +00:00
|
|
|
fields = ['first_name', 'last_name', 'birth_date']
|
2017-08-16 13:12:49 +00:00
|
|
|
success_url = '/children'
|
2017-08-15 20:24:55 +00:00
|
|
|
|
|
|
|
|
2017-08-16 16:46:26 +00:00
|
|
|
class ChildDelete(LoginRequiredMixin, DeleteView):
|
2017-08-16 12:49:58 +00:00
|
|
|
model = Child
|
2017-08-16 13:43:34 +00:00
|
|
|
success_url = '/children'
|
2017-08-16 15:16:27 +00:00
|
|
|
|
|
|
|
|
2017-08-16 16:46:26 +00:00
|
|
|
class DiaperChangeList(LoginRequiredMixin, ListView):
|
2017-08-16 15:16:27 +00:00
|
|
|
model = DiaperChange
|
|
|
|
|
|
|
|
|
2017-08-16 16:46:26 +00:00
|
|
|
class DiaperChangeAdd(LoginRequiredMixin, CreateView):
|
2017-08-16 15:16:27 +00:00
|
|
|
model = DiaperChange
|
|
|
|
fields = ['child', 'time', 'wet', 'solid', 'color']
|
|
|
|
success_url = '/changes'
|
|
|
|
|
|
|
|
|
2017-08-16 16:46:26 +00:00
|
|
|
class DiaperChangeUpdate(LoginRequiredMixin, UpdateView):
|
2017-08-16 15:16:27 +00:00
|
|
|
model = DiaperChange
|
|
|
|
fields = ['child', 'time', 'wet', 'solid', 'color']
|
|
|
|
success_url = '/changes'
|
|
|
|
|
|
|
|
|
2017-08-16 16:46:26 +00:00
|
|
|
class DiaperChangeDelete(LoginRequiredMixin, DeleteView):
|
2017-08-16 15:16:27 +00:00
|
|
|
model = DiaperChange
|
|
|
|
success_url = '/changes'
|
|
|
|
|
|
|
|
|
2017-08-16 16:46:26 +00:00
|
|
|
class FeedingList(LoginRequiredMixin, ListView):
|
2017-08-16 15:16:27 +00:00
|
|
|
model = Feeding
|
|
|
|
|
|
|
|
|
2017-08-16 16:46:26 +00:00
|
|
|
class FeedingAdd(LoginRequiredMixin, CreateView):
|
2017-08-16 15:16:27 +00:00
|
|
|
model = Feeding
|
|
|
|
fields = ['child', 'start', 'end', 'type', 'method']
|
|
|
|
success_url = '/feedings'
|
|
|
|
|
|
|
|
|
2017-08-16 16:46:26 +00:00
|
|
|
class FeedingUpdate(LoginRequiredMixin, UpdateView):
|
2017-08-16 15:16:27 +00:00
|
|
|
model = Feeding
|
|
|
|
fields = ['child', 'start', 'end', 'type', 'method']
|
|
|
|
success_url = '/feedings'
|
|
|
|
|
|
|
|
|
2017-08-16 16:46:26 +00:00
|
|
|
class FeedingDelete(LoginRequiredMixin, DeleteView):
|
2017-08-16 15:16:27 +00:00
|
|
|
model = Feeding
|
|
|
|
success_url = '/feedings'
|
|
|
|
|
|
|
|
|
2017-08-16 16:46:26 +00:00
|
|
|
class NoteList(LoginRequiredMixin, ListView):
|
2017-08-16 15:16:27 +00:00
|
|
|
model = Note
|
|
|
|
|
|
|
|
|
2017-08-16 16:46:26 +00:00
|
|
|
class NoteAdd(LoginRequiredMixin, CreateView):
|
2017-08-16 15:16:27 +00:00
|
|
|
model = Note
|
|
|
|
fields = ['child', 'note']
|
|
|
|
success_url = '/notes'
|
|
|
|
|
|
|
|
|
2017-08-16 16:46:26 +00:00
|
|
|
class NoteUpdate(LoginRequiredMixin, UpdateView):
|
2017-08-16 15:16:27 +00:00
|
|
|
model = Note
|
|
|
|
fields = ['child', 'note']
|
|
|
|
success_url = '/notes'
|
|
|
|
|
|
|
|
|
2017-08-16 16:46:26 +00:00
|
|
|
class NoteDelete(LoginRequiredMixin, DeleteView):
|
2017-08-16 15:16:27 +00:00
|
|
|
model = Note
|
|
|
|
success_url = '/notes'
|
|
|
|
|
|
|
|
|
2017-08-16 16:46:26 +00:00
|
|
|
class SleepList(LoginRequiredMixin, ListView):
|
2017-08-16 15:16:27 +00:00
|
|
|
model = Sleep
|
|
|
|
|
|
|
|
|
2017-08-16 16:46:26 +00:00
|
|
|
class SleepAdd(LoginRequiredMixin, CreateView):
|
2017-08-16 15:16:27 +00:00
|
|
|
model = Sleep
|
|
|
|
fields = ['child', 'start', 'end']
|
|
|
|
success_url = '/sleep'
|
|
|
|
|
|
|
|
|
2017-08-16 16:46:26 +00:00
|
|
|
class SleepUpdate(LoginRequiredMixin, UpdateView):
|
2017-08-16 15:16:27 +00:00
|
|
|
model = Sleep
|
|
|
|
fields = ['child', 'start', 'end']
|
|
|
|
success_url = '/sleep'
|
|
|
|
|
|
|
|
|
2017-08-16 16:46:26 +00:00
|
|
|
class SleepDelete(LoginRequiredMixin, DeleteView):
|
2017-08-16 15:16:27 +00:00
|
|
|
model = Sleep
|
|
|
|
success_url = '/sleep'
|
|
|
|
|
|
|
|
|
2017-08-16 16:46:26 +00:00
|
|
|
class TummyTimeList(LoginRequiredMixin, ListView):
|
2017-08-16 15:16:27 +00:00
|
|
|
model = TummyTime
|
|
|
|
|
|
|
|
|
2017-08-16 16:46:26 +00:00
|
|
|
class TummyTimeAdd(LoginRequiredMixin, CreateView):
|
2017-08-16 15:16:27 +00:00
|
|
|
model = TummyTime
|
|
|
|
fields = ['child', 'start', 'end', 'milestone']
|
|
|
|
success_url = '/tummy-time'
|
|
|
|
|
|
|
|
|
2017-08-16 16:46:26 +00:00
|
|
|
class TummyTimeUpdate(LoginRequiredMixin, UpdateView):
|
2017-08-16 15:16:27 +00:00
|
|
|
model = TummyTime
|
|
|
|
fields = ['child', 'start', 'end', 'milestone']
|
|
|
|
success_url = '/tummy-time'
|
|
|
|
|
|
|
|
|
2017-08-16 16:46:26 +00:00
|
|
|
class TummyTimeDelete(LoginRequiredMixin, DeleteView):
|
2017-08-16 15:16:27 +00:00
|
|
|
model = TummyTime
|
|
|
|
success_url = '/tummy-time'
|