feat: Add initial views for the orders application.

This commit is contained in:
2026-01-26 19:59:23 +03:00
parent d947f4eee7
commit f140469a56

View File

@@ -16,11 +16,18 @@ from inventory.models import Reservation
import json
from django.utils import timezone # Added for default date filter
def order_list(request):
"""
Список всех заказов с фильтрацией и поиском
Использует django-filter для фильтрации данных
"""
# Если параметров нет вообще (первый заход), редиректим на "Сегодня"
if not request.GET:
today = timezone.localdate().isoformat()
return redirect(f'{request.path}?delivery_date_after={today}&delivery_date_before={today}')
# Базовый queryset с оптимизацией запросов
orders = Order.objects.select_related(
'customer', 'delivery', 'delivery__address', 'delivery__pickup_warehouse', 'status' # Добавлен 'status' для избежания N+1