Fix: Removed that when there was nothign in order no commit add woud be done.
This commit is contained in:
parent
35f20e4f63
commit
321923b056
2 changed files with 15 additions and 9 deletions
|
|
@ -39,17 +39,21 @@ class compare:
|
|||
|
||||
OUT: True, False if succeded adding to db
|
||||
'''
|
||||
|
||||
if compare.verifie_order(ordered_list):
|
||||
#products = Product()
|
||||
order = Order(desk)
|
||||
session.add(order)
|
||||
session.commit()
|
||||
order = Order(desk)
|
||||
if compare.verifie_order(ordered_list):
|
||||
is_emtpy = True #check if nothing in prouduct if True dont commit.
|
||||
for product in ordered_list:
|
||||
if int(product[0]) > 0: #dont add not ordered to list
|
||||
if is_emtpy: #first time enter in loop
|
||||
session.add(order)
|
||||
session.commit()
|
||||
productDB = Product(quantity=int(product[0]),name=product[1],order_id = order.id)
|
||||
|
||||
session.add(productDB)
|
||||
session.add(productDB)
|
||||
is_emtpy = False
|
||||
if is_emtpy:
|
||||
return False
|
||||
|
||||
session.commit()
|
||||
logger.success("Order at desk "+ str(desk) +" resived")
|
||||
# add a new ordered_list to the database
|
||||
|
|
|
|||
|
|
@ -116,7 +116,6 @@ def orders(): #TODO on new orderGet refresh orders list
|
|||
|
||||
@app.route("/order_get", methods=['GET','POST'])
|
||||
def order_get():
|
||||
desk= 1
|
||||
global config
|
||||
#POST order
|
||||
if request.method == 'POST' and config['SETTINGS']['lockqrcode_whit_secret'] == 'True':
|
||||
|
|
@ -132,8 +131,11 @@ def order_get():
|
|||
# Adding order to DB
|
||||
if compare.process_main(ordered_list, desk):
|
||||
return '<h1>your order got ressived!</h1>'
|
||||
else:
|
||||
#TODO IF nothing ordered send back to main and say something in a txt box
|
||||
return '<h1>You have selected nothing try again</h1>'
|
||||
return '<h1>your order coudnt be ressived try again Error:SQL </h1>'
|
||||
|
||||
|
||||
# Veriefie if auth or not from GET
|
||||
elif request.method == 'GET':
|
||||
desk = int(request.args['desk'])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue