98 lines
3.1 KiB
Python
98 lines
3.1 KiB
Python
from flask import request, jsonify, Blueprint
|
|
from geruecht.decorator import login_required
|
|
import geruecht.controller.mainController as mc
|
|
from geruecht.model import GASTRO
|
|
from geruecht.logger import getCreditLogger, getDebugLogger
|
|
|
|
debug = getDebugLogger()
|
|
|
|
gastrouser = Blueprint('gastrouser', __name__)
|
|
|
|
mainController = mc.MainController()
|
|
|
|
|
|
@gastrouser.route('/gastro/setDrink', methods=['POST'])
|
|
@login_required(groups=[GASTRO])
|
|
def setDrink(**kwargs):
|
|
debug.info("/gastro/setDrink")
|
|
try:
|
|
data = request.get_json()
|
|
retVal = mainController.setDrinkPrice(data)
|
|
debug.debug("return {{ {} }}".format(retVal))
|
|
return jsonify(retVal)
|
|
except Exception as err:
|
|
debug.debug("exception", exc_info=True)
|
|
return jsonify({"error": str(err)}), 500
|
|
|
|
|
|
@gastrouser.route('/gastro/updateDrink', methods=['POST'])
|
|
@login_required(groups=[GASTRO])
|
|
def updateDrink(**kwargs):
|
|
debug.info("/gastro/updateDrink")
|
|
try:
|
|
data = request.get_json()
|
|
retVal = mainController.updateDrinkPrice(data)
|
|
debug.debug("return {{ {} }}".format(retVal))
|
|
return jsonify(retVal)
|
|
except Exception as err:
|
|
debug.debug("exception", exc_info=True)
|
|
return jsonify({"error": str(err)}), 500
|
|
|
|
|
|
@gastrouser.route('/gastro/deleteDrink', methods=['POST'])
|
|
@login_required(groups=[GASTRO])
|
|
def deleteDrink(**kwargs):
|
|
debug.info("/gastro/dleteDrink")
|
|
try:
|
|
data = request.get_json()
|
|
id = data['id']
|
|
mainController.deletDrinkPrice({"id": id})
|
|
debug.debug("return ok")
|
|
return jsonify({"ok": "ok"})
|
|
except Exception as err:
|
|
debug.debug("exception", exc_info=True)
|
|
return jsonify({"error": str(err)}), 500
|
|
|
|
|
|
@gastrouser.route('/gastro/setDrinkType', methods=['POST'])
|
|
@login_required(groups=[GASTRO])
|
|
def setType(**kwark):
|
|
debug.info("/gastro/setDrinkType")
|
|
try:
|
|
data = request.get_json()
|
|
name = data['name']
|
|
retVal = mainController.setDrinkType(name)
|
|
debug.debug("return {{ {} }}".format(retVal))
|
|
return jsonify(retVal)
|
|
except Exception as err:
|
|
debug.debug("exception", exc_info=True)
|
|
return jsonify({"error": str(err)}), 500
|
|
|
|
|
|
@gastrouser.route('/gastro/updateDrinkType', methods=['POST'])
|
|
@login_required(groups=[GASTRO])
|
|
def updateType(**kwargs):
|
|
debug.info("/gastro/updateDrinkType")
|
|
try:
|
|
data = request.get_json()
|
|
retVal = mainController.updateDrinkType(data)
|
|
debug.debug("return {{ {} }}".format(retVal))
|
|
return jsonify(retVal)
|
|
except Exception as err:
|
|
debug.debug("exception", exc_info=True)
|
|
return jsonify({"error": str(err)}), 500
|
|
|
|
|
|
@gastrouser.route('/gastro/deleteDrinkType', methods=['POST'])
|
|
@login_required(groups=[GASTRO])
|
|
def deleteType(**kwargs):
|
|
debug.info("/gastro/deleteDrinkType")
|
|
try:
|
|
data = request.get_json()
|
|
mainController.deleteDrinkType(data)
|
|
debug.debug("return ok")
|
|
return jsonify({"ok": "ok"})
|
|
except Exception as err:
|
|
debug.debug("exception", exc_info=True)
|
|
return jsonify({"error": str(err)}), 500
|