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:57:46 +00:00
|
|
|
from .forms import (ChildForm, DiaperChangeForm, FeedingForm, SleepForm,
|
|
|
|
TummyTimeForm)
|
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 12:49:58 +00:00
|
|
|
model = Child
|
2017-08-16 18:57:46 +00:00
|
|
|
form_class = ChildForm
|
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-16 18:57:46 +00:00
|
|
|
form_class = ChildForm
|
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
|
2017-08-16 18:57:46 +00:00
|
|
|
form_class = DiaperChangeForm
|
2017-08-16 15:16:27 +00:00
|
|
|
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
|
2017-08-16 18:57:46 +00:00
|
|
|
form_class = DiaperChangeForm
|
2017-08-16 15:16:27 +00:00
|
|
|
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
|
2017-08-16 18:57:46 +00:00
|
|
|
form_class = FeedingForm
|
2017-08-16 15:16:27 +00:00
|
|
|
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
|
2017-08-16 18:57:46 +00:00
|
|
|
form_class = FeedingForm
|
2017-08-16 15:16:27 +00:00
|
|
|
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
|
2017-08-16 18:57:46 +00:00
|
|
|
form_class = SleepForm
|
2017-08-16 15:16:27 +00:00
|
|
|
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
|
2017-08-16 18:57:46 +00:00
|
|
|
form_class = SleepForm
|
2017-08-16 15:16:27 +00:00
|
|
|
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
|
2017-08-16 18:57:46 +00:00
|
|
|
form_class = TummyTimeForm
|
2017-08-16 15:16:27 +00:00
|
|
|
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
|
2017-08-16 18:57:46 +00:00
|
|
|
form_class = TummyTimeForm
|
2017-08-16 15:16:27 +00:00
|
|
|
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'
|