From 172d5d1e085eea4da0f1e4c3876aa4e685e35a27 Mon Sep 17 00:00:00 2001 From: Midgard Date: Sat, 29 Feb 2020 15:40:14 +0100 Subject: [PATCH] Fix dish change detection once and for all --- app/templates/order.html | 2 +- app/views/order.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/templates/order.html b/app/templates/order.html index 7d091a7..cc3bba6 100644 --- a/app/templates/order.html +++ b/app/templates/order.html @@ -53,8 +53,8 @@ {{ util.render_form_field_errors(form.dish_id) }} + {% if dish and dish.choices %} - {% for (choice_type, choice) in dish.choices %}

diff --git a/app/views/order.py b/app/views/order.py index 8b407cf..c19a7c8 100644 --- a/app/views/order.py +++ b/app/views/order.py @@ -134,8 +134,8 @@ def order_item_create(order_id: int) -> typing.Any: form.populate(current_order.location) if form.is_submitted(): - form_for_dish = request.form.get("form_for_dish_id") - dish_was_changed = form_for_dish is not None and form_for_dish != dish_id + form_for_dish = request.form["form_for_dish"] + dish_was_changed = form_for_dish != "" and form_for_dish != dish_id # The form's validation tests that dish_id is valid and gives a friendly error if it's not choices = location.dish_by_id(form.dish_id.data).choices