Fix dish change detection once and for all

This commit is contained in:
Midgard 2020-02-29 15:40:14 +01:00
parent 8aa50d1bd9
commit 172d5d1e08
Signed by: midgard
GPG key ID: 511C112F1331BBB4
2 changed files with 3 additions and 3 deletions

View file

@ -53,8 +53,8 @@
{{ util.render_form_field_errors(form.dish_id) }} {{ util.render_form_field_errors(form.dish_id) }}
</div> </div>
<input type="hidden" name="form_for_dish" value="{{ dish.id }}" />
{% if dish and dish.choices %} {% if dish and dish.choices %}
<input type="hidden" name="form_for_dish" value="{{ dish.id }}" />
{% for (choice_type, choice) in dish.choices %} {% for (choice_type, choice) in dish.choices %}
<div class="form-group select2-container select2"> <div class="form-group select2-container select2">
<label class="control-label" for="choice_{{ choice.id }}">{{ choice.name }}</label><br/> <label class="control-label" for="choice_{{ choice.id }}">{{ choice.name }}</label><br/>

View file

@ -134,8 +134,8 @@ def order_item_create(order_id: int) -> typing.Any:
form.populate(current_order.location) form.populate(current_order.location)
if form.is_submitted(): if form.is_submitted():
form_for_dish = request.form.get("form_for_dish_id") form_for_dish = request.form["form_for_dish"]
dish_was_changed = form_for_dish is not None and form_for_dish != dish_id 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 # 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 choices = location.dish_by_id(form.dish_id.data).choices