mybuddy/core/views.py

33 lines
697 B
Python
Raw Normal View History

2017-08-15 19:14:03 +00:00
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
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 12:49:58 +00:00
from .models import Child
2017-08-15 19:14:03 +00:00
2017-08-15 20:24:55 +00:00
class Index(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 13:12:49 +00:00
class ChildList(ListView):
model = Child
2017-08-16 12:49:58 +00:00
class ChildAdd(CreateView):
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 12:49:58 +00:00
class ChildUpdate(UpdateView):
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 12:49:58 +00:00
class ChildDelete(DeleteView):
model = Child