feat: Add initial views for the orders application.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user