2020-03-01 18:20:47 +00:00
|
|
|
from flask import request, jsonify, Blueprint
|
|
|
|
from geruecht.decorator import login_required
|
|
|
|
import geruecht.controller.userController as uc
|
|
|
|
from geruecht.model import GASTRO
|
2020-03-10 08:19:11 +00:00
|
|
|
from geruecht.logger import getCreditLogger, getDebugLogger
|
|
|
|
|
|
|
|
debug = getDebugLogger()
|
2020-03-01 18:20:47 +00:00
|
|
|
|
|
|
|
gastrouser = Blueprint('gastrouser', __name__)
|
|
|
|
|
|
|
|
userController = uc.UserController()
|
|
|
|
|
|
|
|
@gastrouser.route('/gastro/setDrink', methods=['POST'])
|
|
|
|
@login_required(groups=[GASTRO])
|
|
|
|
def setDrink(**kwargs):
|
2020-03-10 08:19:11 +00:00
|
|
|
debug.info("/gastro/setDrink")
|
2020-03-01 18:20:47 +00:00
|
|
|
try:
|
|
|
|
data = request.get_json()
|
|
|
|
retVal = userController.setDrinkPrice(data)
|
2020-03-10 08:19:11 +00:00
|
|
|
debug.debug("return {{}}".format(retVal))
|
2020-03-01 18:20:47 +00:00
|
|
|
return jsonify(retVal)
|
|
|
|
except Exception as err:
|
2020-03-10 08:19:11 +00:00
|
|
|
debug.debug("exception", exc_info=True)
|
2020-03-01 18:20:47 +00:00
|
|
|
return jsonify({"error": str(err)}), 500
|
|
|
|
|
|
|
|
@gastrouser.route('/gastro/updateDrink', methods=['POST'])
|
|
|
|
@login_required(groups=[GASTRO])
|
|
|
|
def updateDrink(**kwargs):
|
2020-03-10 08:19:11 +00:00
|
|
|
debug.info("/gastro/updateDrink")
|
2020-03-01 18:20:47 +00:00
|
|
|
try:
|
|
|
|
data = request.get_json()
|
|
|
|
retVal = userController.updateDrinkPrice(data)
|
2020-03-10 08:19:11 +00:00
|
|
|
debug.debug("return {{}}".format(retVal))
|
2020-03-01 18:20:47 +00:00
|
|
|
return jsonify(retVal)
|
|
|
|
except Exception as err:
|
2020-03-10 08:19:11 +00:00
|
|
|
debug.debug("exception", exc_info=True)
|
2020-03-01 18:20:47 +00:00
|
|
|
return jsonify({"error": str(err)}), 500
|
|
|
|
|
|
|
|
@gastrouser.route('/gastro/deleteDrink', methods=['POST'])
|
|
|
|
@login_required(groups=[GASTRO])
|
|
|
|
def deleteDrink(**kwargs):
|
2020-03-10 08:19:11 +00:00
|
|
|
debug.info("/gastro/dleteDrink")
|
2020-03-01 18:20:47 +00:00
|
|
|
try:
|
|
|
|
data = request.get_json()
|
|
|
|
id = data['id']
|
|
|
|
retVal = userController.deletDrinkPrice({"id": id})
|
2020-03-10 08:19:11 +00:00
|
|
|
debug.debug("return ok")
|
2020-03-01 18:20:47 +00:00
|
|
|
return jsonify({"ok": "ok"})
|
|
|
|
except Exception as err:
|
2020-03-10 08:19:11 +00:00
|
|
|
debug.debug("exception", exc_info=True)
|
2020-03-01 18:20:47 +00:00
|
|
|
return jsonify({"error": str(err)}), 500
|
|
|
|
|
|
|
|
@gastrouser.route('/gastro/setDrinkType', methods=['POST'])
|
|
|
|
@login_required(groups=[GASTRO])
|
|
|
|
def setType(**kwark):
|
2020-03-10 08:19:11 +00:00
|
|
|
debug.info("/gastro/setDrinkType")
|
2020-03-01 18:20:47 +00:00
|
|
|
try:
|
|
|
|
data = request.get_json()
|
|
|
|
name = data['name']
|
|
|
|
retVal = userController.setDrinkType(name)
|
2020-03-10 08:19:11 +00:00
|
|
|
debug.debug("return {{}}".format(retVal))
|
2020-03-01 18:20:47 +00:00
|
|
|
return jsonify(retVal)
|
|
|
|
except Exception as err:
|
2020-03-10 08:19:11 +00:00
|
|
|
debug.debug("exception", exc_info=True)
|
2020-03-01 18:20:47 +00:00
|
|
|
return jsonify({"error": str(err)}), 500
|
|
|
|
|
|
|
|
@gastrouser.route('/gastro/updateDrinkType', methods=['POST'])
|
|
|
|
@login_required(groups=[GASTRO])
|
|
|
|
def updateType(**kwargs):
|
2020-03-10 08:19:11 +00:00
|
|
|
debug.info("/gastro/updateDrinkType")
|
2020-03-01 18:20:47 +00:00
|
|
|
try:
|
|
|
|
data = request.get_json()
|
|
|
|
retVal = userController.updateDrinkType(data)
|
2020-03-10 08:19:11 +00:00
|
|
|
debug.debug("return {{}}".format(retVal))
|
2020-03-01 18:20:47 +00:00
|
|
|
return jsonify(retVal)
|
|
|
|
except Exception as err:
|
2020-03-10 08:19:11 +00:00
|
|
|
debug.debug("exception", exc_info=True)
|
2020-03-01 18:20:47 +00:00
|
|
|
return jsonify({"error": str(err)}), 500
|
|
|
|
|
|
|
|
@gastrouser.route('/gastro/deleteDrinkType', methods=['POST'])
|
|
|
|
@login_required(groups=[GASTRO])
|
|
|
|
def deleteType(**kwargs):
|
2020-03-10 08:19:11 +00:00
|
|
|
debug.info("/gastro/deleteDrinkType")
|
2020-03-01 18:20:47 +00:00
|
|
|
try:
|
|
|
|
data = request.get_json()
|
|
|
|
userController.deleteDrinkType(data)
|
2020-03-10 08:19:11 +00:00
|
|
|
debug.debug("return ok")
|
2020-03-01 18:20:47 +00:00
|
|
|
return jsonify({"ok": "ok"})
|
|
|
|
except Exception as err:
|
2020-03-10 08:19:11 +00:00
|
|
|
debug.debug("exception", exc_info=True)
|
2020-03-01 18:20:47 +00:00
|
|
|
return jsonify({"error": str(err)}), 500
|
|
|
|
|