mybuddy/core/views.py

142 lines
3.1 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 (ChildForm, DiaperChangeForm, FeedingForm, SleepForm,
TummyTimeForm)
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):
2017-08-16 12:49:58 +00:00
model = Child
form_class = ChildForm
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
form_class = ChildForm
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
form_class = DiaperChangeForm
2017-08-16 15:16:27 +00:00
success_url = '/changes'
class DiaperChangeUpdate(LoginRequiredMixin, UpdateView):
2017-08-16 15:16:27 +00:00
model = DiaperChange
form_class = DiaperChangeForm
2017-08-16 15:16:27 +00:00
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
form_class = FeedingForm
2017-08-16 15:16:27 +00:00
success_url = '/feedings'
class FeedingUpdate(LoginRequiredMixin, UpdateView):
2017-08-16 15:16:27 +00:00
model = Feeding
form_class = FeedingForm
2017-08-16 15:16:27 +00:00
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
form_class = SleepForm
2017-08-16 15:16:27 +00:00
success_url = '/sleep'
class SleepUpdate(LoginRequiredMixin, UpdateView):
2017-08-16 15:16:27 +00:00
model = Sleep
form_class = SleepForm
2017-08-16 15:16:27 +00:00
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
form_class = TummyTimeForm
2017-08-16 15:16:27 +00:00
success_url = '/tummy-time'
class TummyTimeUpdate(LoginRequiredMixin, UpdateView):
2017-08-16 15:16:27 +00:00
model = TummyTime
form_class = TummyTimeForm
2017-08-16 15:16:27 +00:00
success_url = '/tummy-time'
class TummyTimeDelete(LoginRequiredMixin, DeleteView):
2017-08-16 15:16:27 +00:00
model = TummyTime
success_url = '/tummy-time'