Skip to content
Snippets Groups Projects
Commit 058ab29c authored by Sindre Hiis-Hauge's avatar Sindre Hiis-Hauge
Browse files

added new function to change new to open for orders

parent d98febd1
No related branches found
No related tags found
No related merge requests found
......@@ -60,15 +60,15 @@ def get_order_available_filter():
cur=mysql.connection.cursor()
#Matches the attribute, which is a
#Matches the attribute, which is a column in the table.
match (attribute):
case "franchise_store_name":
get_orders_available_filter= cur.execute("SELECT * FROM `order` WHERE `state` = 'Skis available' AND `franchise_store_name` = %s",(value,))
# This does not work for some reason
''' This does not work for some reason
#sql="SELECT * FROM `order` WHERE `state` = 'Skis available' AND `franchise_store_name` = %s"
#args=['%' + value + '%']
#get_orders_available_filter= cur.execute(sql,args)
#get_orders_available_filter= cur.execute(sql,args)'''
case "total_price":
get_orders_available_filter= cur.execute("SELECT * FROM `order` WHERE `state` = 'Skis available' AND `total_price` = %s",(value,))
......@@ -99,5 +99,30 @@ def get_order_available_filter():
return jsonify(get_orders_available_filter),200
@app.route('/POST_orders_open',methods=['PUT'])
def POST_order_open():
if request.method == 'PUT':
data = request.get_json()
order_number=data['order_number']
cur=mysql.connection.cursor()
post_orders_open= cur.execute("UPDATE `order` SET `state` = 'open' WHERE `state`= 'new' AND `order_number` = %s",(order_number,))
order_info= cur.execute("SELECT * FROM `order`")
mysql.connection.commit()
if post_orders_open >0:
post_orders_open = cur.fetchall()
else:
return jsonify("No orders found"),400
cur.close()
return jsonify(order_info,post_orders_open),200
if __name__ == '__main__':
app.run(debug=True)
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment