Logik für FreeDrinkListHistoryWorkgroup
Es können nun auch Freigetränke mit Grund und Beschreibung des Grundes erstellt werden. Count wird erstmal vernachlässigt.
This commit is contained in:
parent
7ac3813782
commit
4a69d54660
|
@ -84,7 +84,11 @@ class Base:
|
|||
def set_free_drink_list_history(self, user, free_drink_list_config):
|
||||
try:
|
||||
cursor = self.db.connection.cursor()
|
||||
cursor.execute(f'insert into free_drink_list_history (timestamp, free_drink_config_id, user_id, free_drink_type_id) values ("{datetime.now()}", {free_drink_list_config["id"]}, {user.id}, {free_drink_list_config["free_drink_type_id"]})')
|
||||
if 'free_drink_list_reason_id' in free_drink_list_config and 'description' in free_drink_list_config:
|
||||
sql = f'insert into free_drink_list_history (timestamp, free_drink_config_id, user_id, free_drink_type_id, free_drink_list_reason_id, description) values ("{datetime.now()}", {free_drink_list_config["id"]}, {user.id}, {free_drink_list_config["free_drink_type_id"]}, {free_drink_list_config["free_drink_list_reason_id"]}, "{free_drink_list_config["description"]}")'
|
||||
else:
|
||||
sql = f'insert into free_drink_list_history (timestamp, free_drink_config_id, user_id, free_drink_type_id) values ("{datetime.now()}", {free_drink_list_config["id"]}, {user.id}, {free_drink_list_config["free_drink_type_id"]})'
|
||||
cursor.execute(sql)
|
||||
self.db.connection.commit()
|
||||
return self.get_free_drink_list_history_by_user(user)
|
||||
except Exception as err:
|
||||
|
@ -112,6 +116,7 @@ class Base:
|
|||
'second': data['timestamp'].second}
|
||||
data['free_drink_config'] = self.get_free_drink_list_config(data['free_drink_config_id'])
|
||||
data['free_drink_type'] = self.get_free_drink_list_type(data['free_drink_type_id'])
|
||||
data['free_drink_list_reason'] = self.get_free_drink_list_reason(data['free_drink_list_reason_id']) if data['free_drink_list_reason_id'] else None
|
||||
return retVal
|
||||
except Exception as err:
|
||||
traceback.print_exc()
|
||||
|
@ -138,3 +143,23 @@ class Base:
|
|||
traceback.print_exc()
|
||||
self.db.connection.rollback()
|
||||
raise DatabaseExecption("Something went wrong with Database: {}".format(err))
|
||||
|
||||
def get_free_drink_list_reason(self, id):
|
||||
try:
|
||||
cursor = self.db.connection.cursor()
|
||||
cursor.execute(f'select * from free_drink_list_reason where id={id}')
|
||||
return cursor.fetchone()
|
||||
except Exception as err:
|
||||
traceback.print_exc()
|
||||
self.db.connection.rollback()
|
||||
raise DatabaseExecption("Something went wrong with Database: {}".format(err))
|
||||
|
||||
def get_free_drink_list_reasons(self):
|
||||
try:
|
||||
cursor = self.db.connection.cursor()
|
||||
cursor.execute(f'select * from free_drink_list_reason')
|
||||
return cursor.fetchall()
|
||||
except Exception as err:
|
||||
traceback.print_exc()
|
||||
self.db.connection.rollback()
|
||||
raise DatabaseExecption("Something went wrong with Database: {}".format(err))
|
|
@ -23,3 +23,6 @@ class Base:
|
|||
def update_free_drink_list_history(self, user, data):
|
||||
db.update_free_drink_list_history(data)
|
||||
return db.get_free_drink_list_history_by_user(user)
|
||||
|
||||
def get_free_drink_list_reasons(self):
|
||||
return db.get_free_drink_list_reasons()
|
|
@ -69,6 +69,18 @@ def _delete_free_drink_list_history(**kwargs):
|
|||
except Exception as err:
|
||||
debug.warning("exception in delete free_dirnk_list_config.", exc_info=True)
|
||||
return jsonify({"error": str(err)}), 500
|
||||
|
||||
@app.route("/freeDrinkListReasons", methods=['GET'])
|
||||
@login_required()
|
||||
def _free_drink_list_reasons(**kwargs):
|
||||
try:
|
||||
debug.info("get free_drink_list_reasons")
|
||||
retVal = mainController.get_free_drink_list_reasons()
|
||||
return jsonify(retVal)
|
||||
except Exception as err:
|
||||
debug.warning("exception in delete free_dirnk_list_reasons.", exc_info=True)
|
||||
return jsonify({"error": str(err)}), 500
|
||||
|
||||
@app.route("/pricelist", methods=['GET'])
|
||||
def _getPricelist():
|
||||
try:
|
||||
|
@ -80,7 +92,6 @@ def _getPricelist():
|
|||
debug.warning("exception in get pricelist.", exc_info=True)
|
||||
return jsonify({"error": str(err)}), 500
|
||||
|
||||
|
||||
@app.route('/drinkTypes', methods=['GET'])
|
||||
def getTypes():
|
||||
try:
|
||||
|
|
Loading…
Reference in New Issue