# -*- coding: utf-8 -*-
"""
Stock (Остатки товаров) views - READ ONLY
GROUP 3: LOW PRIORITY - Справочник состояния
"""
from django.views.generic import ListView, DetailView
from django.contrib.auth.mixins import LoginRequiredMixin
from ..models import Stock


class StockListView(LoginRequiredMixin, ListView):
    """Список всех остатков товаров на всех складах"""
    model = Stock
    template_name = 'inventory/stock/stock_list.html'
    context_object_name = 'stocks'
    paginate_by = 30

    def get_queryset(self):
        # Показываем все остатки, включая нулевые (для полной видимости)
        return Stock.objects.select_related('product', 'warehouse').order_by('warehouse', 'product')


class StockDetailView(LoginRequiredMixin, DetailView):
    """Детальная информация по остаткам конкретного товара"""
    model = Stock
    template_name = 'inventory/stock/stock_detail.html'
    context_object_name = 'stock'
