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 0000000..3749a6d Binary files /dev/null and b/Tools/__pycache__/qrGenerator.cpython-312.pyc differ diff --git a/app.py b/app.py index 0e0feda..0901344 100644 --- a/app.py +++ b/app.py @@ -20,7 +20,7 @@ you want async logging. def run(): #TODO: sys.stderr back to a file log?? logger.add(sys.stderr, format="{time} {level} {message}", filter="startup", level="INFO") logger.add(sys.stderr, backtrace=True, diagnose=config['OTHER']['log_diagnose']) - app.run(debug=False) + app.run(debug=False, host="0.0.0.0") if __name__ == "__main__": #First startup is handled in DB/handler