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 SaleOrder

@method_decorator(login_required, name='dispatch')
class SalesListView(ListView):
    model = SaleOrder
    template_name = 'sales/sales_list.html'
    context_object_name = 'sale_orders'
    paginate_by = 20

@method_decorator(login_required, name='dispatch')
class SalesDetailView(DetailView):
    model = SaleOrder
    template_name = 'sales/sales_detail.html'
    context_object_name = 'sale_order'
