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 @@

#{{ dish.id }} {{ dish.title }} - {{ dish.station }} + + {% if dish.new_station %} + {{ dish.new_station.friendly_name }} + {% else %} + {{ dish.station }} + {% endif %} + {% if dish.in_stock %} check diff --git a/online_store/templates/online_store/menu.html b/online_store/templates/online_store/menu.html index 3373784..23abfb9 100644 --- a/online_store/templates/online_store/menu.html +++ b/online_store/templates/online_store/menu.html @@ -19,13 +19,19 @@

{{menu.menu.title}}