Change forgotten order_id to order_slug in a few places
This commit is contained in:
parent
0a0d13c0dc
commit
44feb1a4ff
5 changed files with 13 additions and 11 deletions
|
@ -44,6 +44,7 @@ class OrderItemAdminModel(ModelBaseView):
|
|||
column_default_sort = ("order_id", True)
|
||||
column_list = [
|
||||
"order_id",
|
||||
"slug",
|
||||
"order.location_name",
|
||||
"user_name",
|
||||
"user",
|
||||
|
|
|
@ -9,6 +9,7 @@ user
|
|||
|
||||
order
|
||||
id
|
||||
slug secret used in URL
|
||||
courier_id
|
||||
location_id HLDS identifier
|
||||
location_name this allows historical orders to keep the same location name
|
||||
|
|
|
@ -348,7 +348,7 @@
|
|||
|
||||
{% if order.can_modify_prices(current_user.id) %}
|
||||
<span style="border-left: 1px solid var(--gray0); display: inline-block;"> </span>
|
||||
<a href="{{ url_for('order_bp.prices', order_id=order.id) }}" class="btn btn-sm">
|
||||
<a href="{{ url_for('order_bp.prices', order_slug=order.slug) }}" class="btn btn-sm">
|
||||
<span class="glyphicon glyphicon-pencil"></span> Edit prices
|
||||
</a>
|
||||
{% endif %}
|
||||
|
|
|
@ -11,10 +11,10 @@
|
|||
{% block container %}
|
||||
<header>
|
||||
<h2 id="order-title">Edit prices</h2>
|
||||
<div>Only applied to <a href="{{ url_for('order_bp.order_from_id', order_id=order.id) }}">order {{ order.id }}</a>. To permanently change prices for {{ order.location_name }}, edit the <a href="https://git.zeus.gent/haldis/menus/-/blob/master/{{order.location_id}}.hlds">HLDS location definition</a>.</div>
|
||||
<div>Only applied to <a href="{{ url_for('order_bp.order_from_slug', order_slug=order.slug) }}">order {{ order.id }}</a>. To permanently change prices for {{ order.location_name }}, edit the <a href="https://git.zeus.gent/haldis/menus/-/blob/master/{{order.location_id}}.hlds">HLDS location definition</a>.</div>
|
||||
</header>
|
||||
|
||||
<form action="{{ url_for('order_bp.prices', order_id=order.id) }}" method="post">
|
||||
<form action="{{ url_for('order_bp.prices', order_slug=order.slug) }}" method="post">
|
||||
<div class="col-md-6" id="per_dish">
|
||||
<h3>Per dish</h3>
|
||||
<div class="noscript">This functionality requires JavaScript.</div>
|
||||
|
@ -86,7 +86,7 @@
|
|||
</div>
|
||||
|
||||
<div>
|
||||
<a href="{{ url_for('order_bp.order_from_id', order_id=order.id) }}" class="btn btn-sm">Cancel</a>
|
||||
<a href="{{ url_for('order_bp.order_from_slug', order_slug=order.slug) }}" class="btn btn-sm">Cancel</a>
|
||||
<button class="btn btn-sm btn-primary">Apply</button>
|
||||
</div>
|
||||
</form>
|
||||
|
|
|
@ -233,9 +233,9 @@ def modify_items(order_slug: str) -> typing.Optional[Response]:
|
|||
return delete_item(order_slug, int(request.form["delete_item"]))
|
||||
user_names = request.form.getlist("user_names")
|
||||
if request.form.get("action") == "mark_paid":
|
||||
return set_items_paid(order_id, user_names, True)
|
||||
return set_items_paid(order_slug, user_names, True)
|
||||
elif request.form.get("action") == "mark_unpaid":
|
||||
return set_items_paid(order_id, user_names, False)
|
||||
return set_items_paid(order_slug, user_names, False)
|
||||
else:
|
||||
abort(404)
|
||||
return None
|
||||
|
@ -328,15 +328,15 @@ def close_order(order_slug: str) -> typing.Optional[Response]:
|
|||
return None
|
||||
|
||||
|
||||
@order_bp.route("/<order_id>/prices", methods=["GET", "POST"])
|
||||
@order_bp.route("/<order_slug>/prices", methods=["GET", "POST"])
|
||||
@login_required
|
||||
def prices(order_id: int) -> typing.Optional[Response]:
|
||||
order = Order.query.filter(Order.id == order_id).first()
|
||||
def prices(order_slug: str) -> typing.Optional[Response]:
|
||||
order = Order.query.filter(Order.slug == order_slug).first()
|
||||
if order is None:
|
||||
abort(404)
|
||||
if not order.can_modify_prices(current_user.id):
|
||||
flash("You cannot modify the prices at this time.", "error")
|
||||
return redirect(url_for("order_bp.order_from_id", order_id=order_id))
|
||||
return redirect(url_for("order_bp.order_from_slug", order_slug=order.slug))
|
||||
|
||||
if request.method == "GET":
|
||||
return render_template(
|
||||
|
@ -366,7 +366,7 @@ def prices(order_id: int) -> typing.Optional[Response]:
|
|||
item.price_modified = datetime.now()
|
||||
db.session.commit()
|
||||
|
||||
return redirect(url_for("order_bp.order_from_id", order_id=order_id))
|
||||
return redirect(url_for("order_bp.order_from_slug", order_slug=order.slug))
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue