Django_Basic_Manufacturing/inventory/views.py

45 lines
1.5 KiB
Python

from django.shortcuts import render, get_object_or_404
from django.views.generic import ListView, DetailView
from django.contrib.auth.decorators import login_required
from django.utils.decorators import method_decorator
from .models import Product, Customer, Supplier
@method_decorator(login_required, name='dispatch')
class ProductListView(ListView):
model = Product
template_name = 'inventory/product_list.html'
context_object_name = 'products'
paginate_by = 20
@method_decorator(login_required, name='dispatch')
class ProductDetailView(DetailView):
model = Product
template_name = 'inventory/product_detail.html'
context_object_name = 'product'
@method_decorator(login_required, name='dispatch')
class CustomerListView(ListView):
model = Customer
template_name = 'inventory/customer_list.html'
context_object_name = 'customers'
paginate_by = 20
@method_decorator(login_required, name='dispatch')
class CustomerDetailView(DetailView):
model = Customer
template_name = 'inventory/customer_detail.html'
context_object_name = 'customer'
@method_decorator(login_required, name='dispatch')
class SupplierListView(ListView):
model = Supplier
template_name = 'inventory/supplier_list.html'
context_object_name = 'suppliers'
paginate_by = 20
@method_decorator(login_required, name='dispatch')
class SupplierDetailView(DetailView):
model = Supplier
template_name = 'inventory/supplier_detail.html'
context_object_name = 'supplier'