mybuddy/core/views.py

141 lines
3.3 KiB
Python
Raw Normal View History

2017-08-15 19:14:03 +00:00
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
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
from .forms import ChildAddForm
2017-08-15 19:14:03 +00:00
2017-08-15 20:24:55 +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
class ChildList(LoginRequiredMixin, ListView):
2017-08-16 13:12:49 +00:00
model = Child
class ChildAdd(LoginRequiredMixin, CreateView):
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
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
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
class DiaperChangeList(LoginRequiredMixin, ListView):
2017-08-16 15:16:27 +00:00
model = DiaperChange
class DiaperChangeAdd(LoginRequiredMixin, CreateView):
2017-08-16 15:16:27 +00:00
model = DiaperChange
fields = ['child', 'time', 'wet', 'solid', 'color']
success_url = '/changes'
class DiaperChangeUpdate(LoginRequiredMixin, UpdateView):
2017-08-16 15:16:27 +00:00
model = DiaperChange
fields = ['child', 'time', 'wet', 'solid', 'color']
success_url = '/changes'
class DiaperChangeDelete(LoginRequiredMixin, DeleteView):
2017-08-16 15:16:27 +00:00
model = DiaperChange
success_url = '/changes'
class FeedingList(LoginRequiredMixin, ListView):
2017-08-16 15:16:27 +00:00
model = Feeding
class FeedingAdd(LoginRequiredMixin, CreateView):
2017-08-16 15:16:27 +00:00
model = Feeding
fields = ['child', 'start', 'end', 'type', 'method']
success_url = '/feedings'
class FeedingUpdate(LoginRequiredMixin, UpdateView):
2017-08-16 15:16:27 +00:00
model = Feeding
fields = ['child', 'start', 'end', 'type', 'method']
success_url = '/feedings'
class FeedingDelete(LoginRequiredMixin, DeleteView):
2017-08-16 15:16:27 +00:00
model = Feeding
success_url = '/feedings'
class NoteList(LoginRequiredMixin, ListView):
2017-08-16 15:16:27 +00:00
model = Note
class NoteAdd(LoginRequiredMixin, CreateView):
2017-08-16 15:16:27 +00:00
model = Note
fields = ['child', 'note']
success_url = '/notes'
class NoteUpdate(LoginRequiredMixin, UpdateView):
2017-08-16 15:16:27 +00:00
model = Note
fields = ['child', 'note']
success_url = '/notes'
class NoteDelete(LoginRequiredMixin, DeleteView):
2017-08-16 15:16:27 +00:00
model = Note
success_url = '/notes'
class SleepList(LoginRequiredMixin, ListView):
2017-08-16 15:16:27 +00:00
model = Sleep
class SleepAdd(LoginRequiredMixin, CreateView):
2017-08-16 15:16:27 +00:00
model = Sleep
fields = ['child', 'start', 'end']
success_url = '/sleep'
class SleepUpdate(LoginRequiredMixin, UpdateView):
2017-08-16 15:16:27 +00:00
model = Sleep
fields = ['child', 'start', 'end']
success_url = '/sleep'
class SleepDelete(LoginRequiredMixin, DeleteView):
2017-08-16 15:16:27 +00:00
model = Sleep
success_url = '/sleep'
class TummyTimeList(LoginRequiredMixin, ListView):
2017-08-16 15:16:27 +00:00
model = TummyTime
class TummyTimeAdd(LoginRequiredMixin, CreateView):
2017-08-16 15:16:27 +00:00
model = TummyTime
fields = ['child', 'start', 'end', 'milestone']
success_url = '/tummy-time'
class TummyTimeUpdate(LoginRequiredMixin, UpdateView):
2017-08-16 15:16:27 +00:00
model = TummyTime
fields = ['child', 'start', 'end', 'milestone']
success_url = '/tummy-time'
class TummyTimeDelete(LoginRequiredMixin, DeleteView):
2017-08-16 15:16:27 +00:00
model = TummyTime
success_url = '/tummy-time'