Fix bug on anonymous order view
Change to temporary message
This commit is contained in:
parent
02cea73a6c
commit
ccb034ef7f
3 changed files with 7 additions and 3 deletions
|
@ -60,7 +60,7 @@ class OrderItemForm(Form):
|
|||
else:
|
||||
return "from {}".format(euro_string(price_range[0]))
|
||||
|
||||
def populate(self, location: Location, dish_id: Optional[str]) -> None:
|
||||
def populate(self, location: Location) -> None:
|
||||
self.dish_id.choices = [
|
||||
(dish.id, (dish.name + ": " + self.format_price_range(dish.price_range())))
|
||||
for dish in location.dishes
|
||||
|
|
|
@ -42,6 +42,9 @@
|
|||
{% if form -%}
|
||||
<div class="col-md-push-1 col-md-10 darker order_order" id="form">
|
||||
<h4>Order:</h4>
|
||||
{% if current_user.is_anonymous() %}
|
||||
<div>Sorry, anonymous ordering is currently broken. Please log in to order.</div>
|
||||
{% else %}
|
||||
<form method="post" action="{{ url_for('order_bp.order_item_create', order_id=order.id) }}">
|
||||
<span class="pull-right">
|
||||
<a class="btn btn-primary" onclick="chooseRandom()">Choose for me</a>
|
||||
|
@ -90,6 +93,7 @@
|
|||
{{ form.submit_button(class='btn btn-primary') }}
|
||||
</div>
|
||||
</form>
|
||||
{% endif %}
|
||||
</div>
|
||||
{%- endif %}
|
||||
</div>
|
||||
|
|
|
@ -60,7 +60,7 @@ def order_from_id(order_id: int, form: OrderForm = None, dish_id=None) -> str:
|
|||
form = AnonOrderItemForm() if current_user.is_anonymous() \
|
||||
else OrderItemForm()
|
||||
if order.location:
|
||||
form.populate(order.location, None)
|
||||
form.populate(order.location)
|
||||
if order.is_closed():
|
||||
form = None
|
||||
total_price = sum([o.price for o in order.items])
|
||||
|
@ -130,7 +130,7 @@ def order_item_create(order_id: int) -> typing.Any:
|
|||
if dish_id and not location.dish_by_id(dish_id):
|
||||
abort(404)
|
||||
form.dish_id.data = dish_id
|
||||
form.populate(current_order.location, dish_id)
|
||||
form.populate(current_order.location)
|
||||
|
||||
# If the form was not submitted (GET request), the form had errors,
|
||||
# or the dish was changed: show form again
|
||||
|
|
Loading…
Reference in a new issue