added feature on new orderGet refresh orders list fixed bug if i order something from desk 2 as first after db entry 2 desk dont show its ordered items only if i add in desk 1 (querys.py)

This commit is contained in:
Tim Berchtold 2025-07-08 16:41:12 +02:00
parent a95e8a00b8
commit 35f20e4f63
10 changed files with 103 additions and 33 deletions

View file

@ -95,16 +95,21 @@ def logout():
def orders(): #TODO on new orderGet refresh orders list
if request.method == 'POST':
order_id = request.form.get('order_id')
action = request.form.get('action') # 'finish' or 'undo'
action = request.form.get('action') # 'refresh', 'finish' or 'undo'
order = session.get(Order, int(order_id))
if order: #SQL error handeling just in case
if action == 'finish':
order.finished = True
elif action == 'undo':
order.finished = False
if action == 'finish':
order = session.get(Order, int(order_id))
order.finished = True
session.commit()
return jsonify(success=True)
elif action == 'undo':
order = session.get(Order, int(order_id))
order.finished = False
session.commit()
return jsonify(success=True)
elif action == 'refresh':
html = render_template('partials/_order_rows.html', orders=get.all_orders())
return jsonify(success=True, html=html)
return jsonify(success=False)
return render_template('orders.html', orders=get.all_orders())
@ -137,11 +142,9 @@ def order_get():
return render_template('index.html', desk=desk, MAX_DESKS=int(config['DEFAULT']['max_desks']), orderableItems = get.valid_products(get_json_=True))
elif config['SETTINGS']['lockqrcode_whit_secret'] == 'False':
return render_template('index.html', desk=desk, MAX_DESKS=int(config['DEFAULT']['max_desks']),orderableItems = get.valid_products(get_json_=True))
else:
return '<h1>Somethign went wrong try again.</h1>' #TODO Make the HTML prettier for all
return '<h1>404 wrong Secret?</h1>' #TODO Make the HTML prettier for all
elif config['SETTINGS']['lockqrcode_whit_secret'] == 'True':
return '<h1>your LOCKQRCODE is invalid.</h1>'
elif config['SETTINGS']['lockqrcode_whit_secret'] == 'True':
return '<h1>your LOCKQRCODE is invalid.</h1>'
return '<h1>Something went wrong went wrong, Try again.</h1>' #TODO Make the HTML prettier for all
else:
return render_template('index.html',desk=desk, MAX_DESKS=int(config['DEFAULT']['max_desks']),orderableItems = get.valid_products(get_json_=True))