2022-03-09 10:33:05 +00:00
|
|
|
from django.shortcuts import render
|
|
|
|
from django.http import HttpResponse
|
2022-03-09 17:13:09 +00:00
|
|
|
from django.template import loader
|
|
|
|
from django.http import Http404
|
2022-03-10 10:33:06 +00:00
|
|
|
from django.urls import reverse
|
|
|
|
from django.views import generic
|
2022-03-09 10:33:05 +00:00
|
|
|
|
2022-03-09 17:13:09 +00:00
|
|
|
from .models import Container, ContainerType
|
2022-03-09 10:33:05 +00:00
|
|
|
|
2022-03-10 10:33:06 +00:00
|
|
|
class IndexView(generic.ListView):
|
|
|
|
template_name = 'container/container_index.html'
|
|
|
|
context_object_name = 'container_list'
|
2022-03-09 17:13:09 +00:00
|
|
|
|
2022-03-10 10:33:06 +00:00
|
|
|
def get_queryset(self):
|
|
|
|
# Return the last five created containers
|
|
|
|
return Container.objects.order_by('-created_ts')[:5]
|
|
|
|
|
|
|
|
class TypeIndexView(generic.ListView):
|
|
|
|
template_name = 'container/container_type_index.html'
|
|
|
|
context_object_name = 'container_type_list'
|
|
|
|
|
|
|
|
def get_queryset(self):
|
|
|
|
# Return the last five created container types
|
|
|
|
return ContainerType.objects.order_by('-created_ts')[:5]
|
|
|
|
|
|
|
|
class DetailView(generic.DetailView):
|
|
|
|
model = Container
|
|
|
|
# template_name = 'container/detail.html'
|
|
|
|
|
|
|
|
class TypeDetailView(generic.DetailView):
|
|
|
|
model = ContainerType
|
|
|
|
context_object_name = 'container_type'
|
|
|
|
template_name = 'container/container_type_detail.html'
|
|
|
|
|
|
|
|
class EditView(generic.DetailView):
|
|
|
|
model = Container
|
|
|
|
|
|
|
|
class DeleteView(generic.DetailView):
|
|
|
|
model = Container
|
2022-03-09 10:33:05 +00:00
|
|
|
|