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_default_sort = ("order_id", True)
|
||||||
column_list = [
|
column_list = [
|
||||||
"order_id",
|
"order_id",
|
||||||
|
"slug",
|
||||||
"order.location_name",
|
"order.location_name",
|
||||||
"user_name",
|
"user_name",
|
||||||
"user",
|
"user",
|
||||||
|
|
|
@ -9,6 +9,7 @@ user
|
||||||
|
|
||||||
order
|
order
|
||||||
id
|
id
|
||||||
|
slug secret used in URL
|
||||||
courier_id
|
courier_id
|
||||||
location_id HLDS identifier
|
location_id HLDS identifier
|
||||||
location_name this allows historical orders to keep the same location name
|
location_name this allows historical orders to keep the same location name
|
||||||
|
|
|
@ -348,7 +348,7 @@
|
||||||
|
|
||||||
{% if order.can_modify_prices(current_user.id) %}
|
{% if order.can_modify_prices(current_user.id) %}
|
||||||
<span style="border-left: 1px solid var(--gray0); display: inline-block;"> </span>
|
<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
|
<span class="glyphicon glyphicon-pencil"></span> Edit prices
|
||||||
</a>
|
</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
@ -11,10 +11,10 @@
|
||||||
{% block container %}
|
{% block container %}
|
||||||
<header>
|
<header>
|
||||||
<h2 id="order-title">Edit prices</h2>
|
<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>
|
</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">
|
<div class="col-md-6" id="per_dish">
|
||||||
<h3>Per dish</h3>
|
<h3>Per dish</h3>
|
||||||
<div class="noscript">This functionality requires JavaScript.</div>
|
<div class="noscript">This functionality requires JavaScript.</div>
|
||||||
|
@ -86,7 +86,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<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>
|
<button class="btn btn-sm btn-primary">Apply</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
|
@ -233,9 +233,9 @@ def modify_items(order_slug: str) -> typing.Optional[Response]:
|
||||||
return delete_item(order_slug, int(request.form["delete_item"]))
|
return delete_item(order_slug, int(request.form["delete_item"]))
|
||||||
user_names = request.form.getlist("user_names")
|
user_names = request.form.getlist("user_names")
|
||||||
if request.form.get("action") == "mark_paid":
|
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":
|
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:
|
else:
|
||||||
abort(404)
|
abort(404)
|
||||||
return None
|
return None
|
||||||
|
@ -328,15 +328,15 @@ def close_order(order_slug: str) -> typing.Optional[Response]:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
@order_bp.route("/<order_id>/prices", methods=["GET", "POST"])
|
@order_bp.route("/<order_slug>/prices", methods=["GET", "POST"])
|
||||||
@login_required
|
@login_required
|
||||||
def prices(order_id: int) -> typing.Optional[Response]:
|
def prices(order_slug: str) -> typing.Optional[Response]:
|
||||||
order = Order.query.filter(Order.id == order_id).first()
|
order = Order.query.filter(Order.slug == order_slug).first()
|
||||||
if order is None:
|
if order is None:
|
||||||
abort(404)
|
abort(404)
|
||||||
if not order.can_modify_prices(current_user.id):
|
if not order.can_modify_prices(current_user.id):
|
||||||
flash("You cannot modify the prices at this time.", "error")
|
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":
|
if request.method == "GET":
|
||||||
return render_template(
|
return render_template(
|
||||||
|
@ -366,7 +366,7 @@ def prices(order_id: int) -> typing.Optional[Response]:
|
||||||
item.price_modified = datetime.now()
|
item.price_modified = datetime.now()
|
||||||
db.session.commit()
|
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