from django.shortcuts import render
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 PurchaseOrder

@method_decorator(login_required, name='dispatch')
class PurchaseListView(ListView):
    model = PurchaseOrder
    template_name = 'purchase/purchase_list.html'
    context_object_name = 'purchase_orders'
    paginate_by = 20

@method_decorator(login_required, name='dispatch')
class PurchaseDetailView(DetailView):
    model = PurchaseOrder
    template_name = 'purchase/purchase_detail.html'
    context_object_name = 'purchase_order'
