From 35f20e4f63c32f24fd16a2428e2ea1db3ba36765 Mon Sep 17 00:00:00 2001 From: Tim Date: Tue, 8 Jul 2025 16:41:12 +0200 Subject: [PATCH] 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) --- .gitignore | 1 + README.md | 4 + Server/DB/querys.py | 3 +- Server/Host/flaskApp.py | 27 ++++--- Server/Host/templates/index.html | 2 +- Server/Host/templates/login.html | 2 +- Server/Host/templates/orders.html | 73 ++++++++++++++---- .../Host/templates/partials/_order_rows.html | 22 ++++++ Tools/__pycache__/qrGenerator.cpython-312.pyc | Bin 0 -> 2788 bytes app.py | 2 +- 10 files changed, 103 insertions(+), 33 deletions(-) create mode 100644 .gitignore create mode 100644 Server/Host/templates/partials/_order_rows.html create mode 100644 Tools/__pycache__/qrGenerator.cpython-312.pyc diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b694934 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.venv \ No newline at end of file diff --git a/README.md b/README.md index 19ae1d2..59bcd54 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,10 @@ Execute in Terminal "python3 -m venv .venv", for the virtual enviroment activate Note: This are early stages of this project listed are missing and planed. + +### DB Delete + +To delete db simple add first_startup = True in Options.ini and remove db.sqlite # To Does --- Must have features / fixes diff --git a/Server/DB/querys.py b/Server/DB/querys.py index a42532f..f721dbf 100644 --- a/Server/DB/querys.py +++ b/Server/DB/querys.py @@ -126,11 +126,10 @@ class get: def all_orders(): # All unfinished orders (finished is False or string "False") result = [] - desk = 1 orders = session.query(Order).filter(Order.finished == 0).all() session.commit() for order in orders: - products = session.query(Product).filter(Product.order_id == order.id , Order.desk_number == desk).all() + products = session.query(Product).filter(Product.order_id == order.id).all() session.commit() list_products = [] for p in products: diff --git a/Server/Host/flaskApp.py b/Server/Host/flaskApp.py index 0b22e59..acbc90a 100644 --- a/Server/Host/flaskApp.py +++ b/Server/Host/flaskApp.py @@ -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 '

Somethign went wrong try again.

' #TODO Make the HTML prettier for all - return '

404 wrong Secret?

' #TODO Make the HTML prettier for all - elif config['SETTINGS']['lockqrcode_whit_secret'] == 'True': - return '

your LOCKQRCODE is invalid.

' + elif config['SETTINGS']['lockqrcode_whit_secret'] == 'True': + return '

your LOCKQRCODE is invalid.

' + return '

Something went wrong went wrong, Try again.

' #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)) diff --git a/Server/Host/templates/index.html b/Server/Host/templates/index.html index 2fbb5e8..80934de 100644 --- a/Server/Host/templates/index.html +++ b/Server/Host/templates/index.html @@ -7,7 +7,7 @@ Document -
+
  • Tisch Nummer
    diff --git a/Server/Host/templates/login.html b/Server/Host/templates/login.html index 462a86a..c94edd5 100644 --- a/Server/Host/templates/login.html +++ b/Server/Host/templates/login.html @@ -20,4 +20,4 @@ - \ No newline at end of file + diff --git a/Server/Host/templates/orders.html b/Server/Host/templates/orders.html index 8fbc6aa..dabf3a8 100644 --- a/Server/Host/templates/orders.html +++ b/Server/Host/templates/orders.html @@ -35,26 +35,31 @@ Action Order-Nr +
    + Last refreshed: 0s ago +
    + {% for order in orders%} - - {{ order[0] }} - -
      - {% for product in order[1] %} -
    • {{ product }}
    • - {% endfor %} -
    - - - - - order {{ order[2] }} - + + {{ order[0] }} + +
      + {% for product in order[1] %} +
    • {{ product }}
    • + {% endfor %} +
    + + + + + order {{ order[2] }} + {% else %} No open orders. {% endfor %} + \ No newline at end of file diff --git a/Server/Host/templates/partials/_order_rows.html b/Server/Host/templates/partials/_order_rows.html new file mode 100644 index 0000000..f77f5d0 --- /dev/null +++ b/Server/Host/templates/partials/_order_rows.html @@ -0,0 +1,22 @@ + +{% for order in orders%} + + {{ order[0] }} + +
      + {% for product in order[1] %} +
    • {{ product }}
    • + {% endfor %} +
    + + + + + order {{ order[2] }} + +{% else %} +No open orders. +{% endfor %} + \ No newline at end of file diff --git a/Tools/__pycache__/qrGenerator.cpython-312.pyc b/Tools/__pycache__/qrGenerator.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..3749a6d2c442d0e398ff793decfdffd973f43ec7 GIT binary patch literal 2788 zcmc&$U2GFa5Z*hV&o;L6g9$WtfDjPsw#Cf&MHCEBXIwWLoxb@uFyqli{5RmJGE zGdr_CGrQl;+&6yzCIr+_l^VR`Lg+E?2y&E!)ddh{kdAaIiK0a=MJ2m0M`hr0(vec4 zio|UWkeyMdElWu?s>%qfi3+i3na`KRs2jTzfwEpm!Y(1O*9dKy>&m=T?7?2n4^h;s ztI+z!rLgM>H*|+3CZ9VGt;@oeWtiy+@0no=+-fq?M!#HM3n?J;cvlZWGlOVpWrPyz zN0laIP)3?B=_lok+=IeWcUWdB(bBq^VlK{&Gz~kLBW0wa(XKH`v-k$}_4UuXB7SI>gSCh6$CrzyAVDE zE%b2FwIJ)V-8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