From ef55964d5d695a48b21d1cf1411557a02b7ad7e7 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 26 Nov 2025 21:01:31 +0000 Subject: [PATCH 1/4] Initial plan From 619278dbb81241461be37d3cbbd7637d3ce1bcad Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 26 Nov 2025 21:22:22 +0000 Subject: [PATCH 2/4] Implement dynamic stations feature with admin interface support Co-authored-by: Collert <17819526+Collert@users.noreply.github.com> --- deliveries/signals.py | 9 +- deliveries/views.py | 12 +- .../templates/new_admin/menus-instance.html | 8 +- online_store/templates/online_store/menu.html | 20 +- online_store/views.py | 39 ++- pos_server/admin.py | 21 +- pos_server/models.py | 230 ++++++++++++++++-- .../templates/pos_server/order-marking.html | 66 ++--- pos_server/templates/pos_server/order.html | 21 +- pos_server/templatetags/custom_filters.py | 89 +++++-- pos_server/views.py | 181 ++++++++++---- 11 files changed, 544 insertions(+), 152 deletions(-) diff --git a/deliveries/signals.py b/deliveries/signals.py index 3782506..0c5f792 100644 --- a/deliveries/signals.py +++ b/deliveries/signals.py @@ -9,9 +9,9 @@ def new_delivery(sender, instance, created, **kwargs): """ Signal handler for new delivery creation. - This function is triggered when a new delivery instance is created. It checks the kitchen, bar, - and general status of the order associated with the delivery instance. If all statuses are either - 2 or 4, it triggers a push notification to inform about the new delivery. + This function is triggered when a new delivery instance is created. It checks if all stations + are complete for the order associated with the delivery instance. If all statuses are complete, + it triggers a push notification to inform about the new delivery. Args: sender (Model): The model class that sent the signal. @@ -22,7 +22,8 @@ def new_delivery(sender, instance, created, **kwargs): Returns: None """ - if instance.order.kitchen_status in [2, 4] and instance.order.bar_status in [2, 4] and instance.order.gng_status in [2, 4]: + # Use the new all_stations_complete method for checking order readiness + if instance.order.all_stations_complete(): trigger_push_notifications( "New delivery!", "New order available to deliver. Check your app!", diff --git a/deliveries/views.py b/deliveries/views.py index 3c7a034..fca2379 100644 --- a/deliveries/views.py +++ b/deliveries/views.py @@ -37,6 +37,10 @@ def ready_orders(request): """ courier = check_if_active_courier(request) today = timezone.localdate() + + # Filter orders that are ready for delivery + # An order is ready when all legacy stations are complete (2 or 4) + # and no dynamic stations are pending (0) or in progress (1) orders = Delivery.objects.filter( order__kitchen_status__in = [2, 4], order__bar_status__in = [2, 4], @@ -44,7 +48,13 @@ def ready_orders(request): completed=False, order__picked_up=False, timestamp__date=today - ) + ).exclude( + # Exclude orders with pending or in-progress dynamic stations + order__status_0_stations__isnull=False + ).exclude( + order__status_1_stations__isnull=False + ).distinct() + if courier: for d in Delivery.objects.filter(completed = False).all(): if d.courier == request.user: diff --git a/new_admin/templates/new_admin/menus-instance.html b/new_admin/templates/new_admin/menus-instance.html index 680383e..c1a2344 100644 --- a/new_admin/templates/new_admin/menus-instance.html +++ b/new_admin/templates/new_admin/menus-instance.html @@ -64,7 +64,13 @@