From ccb034ef7ffcd5ffb5b556ae95d602be2bc79b6d Mon Sep 17 00:00:00 2001 From: Midgard Date: Wed, 26 Feb 2020 18:05:56 +0100 Subject: [PATCH] Fix bug on anonymous order view Change to temporary message --- app/forms.py | 2 +- app/templates/order.html | 4 ++++ app/views/order.py | 4 ++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/forms.py b/app/forms.py index f57dc0c..999c0ca 100644 --- a/app/forms.py +++ b/app/forms.py @@ -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 diff --git a/app/templates/order.html b/app/templates/order.html index ade38f3..0c74e1f 100644 --- a/app/templates/order.html +++ b/app/templates/order.html @@ -42,6 +42,9 @@ {% if form -%}

Order:

+{% if current_user.is_anonymous() %} +
Sorry, anonymous ordering is currently broken. Please log in to order.
+{% else %}
Choose for me @@ -90,6 +93,7 @@ {{ form.submit_button(class='btn btn-primary') }}
+{% endif %} {%- endif %} diff --git a/app/views/order.py b/app/views/order.py index 843c50f..0c2d3a1 100644 --- a/app/views/order.py +++ b/app/views/order.py @@ -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