flaschengeist/geruecht/gastro/routes.py

72 lines
2.2 KiB
Python

from flask import request, jsonify, Blueprint
from geruecht.decorator import login_required
import geruecht.controller.userController as uc
from geruecht.model import GASTRO
gastrouser = Blueprint('gastrouser', __name__)
userController = uc.UserController()
@gastrouser.route('/gastro/setDrink', methods=['POST'])
@login_required(groups=[GASTRO])
def setDrink(**kwargs):
try:
data = request.get_json()
retVal = userController.setDrinkPrice(data)
return jsonify(retVal)
except Exception as err:
return jsonify({"error": str(err)}), 500
@gastrouser.route('/gastro/updateDrink', methods=['POST'])
@login_required(groups=[GASTRO])
def updateDrink(**kwargs):
try:
data = request.get_json()
retVal = userController.updateDrinkPrice(data)
return jsonify(retVal)
except Exception as err:
return jsonify({"error": str(err)}), 500
@gastrouser.route('/gastro/deleteDrink', methods=['POST'])
@login_required(groups=[GASTRO])
def deleteDrink(**kwargs):
try:
data = request.get_json()
id = data['id']
retVal = userController.deletDrinkPrice({"id": id})
return jsonify({"ok": "ok"})
except Exception as err:
return jsonify({"error": str(err)}), 500
@gastrouser.route('/gastro/setDrinkType', methods=['POST'])
@login_required(groups=[GASTRO])
def setType(**kwark):
try:
data = request.get_json()
name = data['name']
retVal = userController.setDrinkType(name)
return jsonify(retVal)
except Exception as err:
return jsonify({"error": str(err)}), 500
@gastrouser.route('/gastro/updateDrinkType', methods=['POST'])
@login_required(groups=[GASTRO])
def updateType(**kwargs):
try:
data = request.get_json()
retVal = userController.updateDrinkType(data)
return jsonify(retVal)
except Exception as err:
return jsonify({"error": str(err)}), 500
@gastrouser.route('/gastro/deleteDrinkType', methods=['POST'])
@login_required(groups=[GASTRO])
def deleteType(**kwargs):
try:
data = request.get_json()
userController.deleteDrinkType(data)
return jsonify({"ok": "ok"})
except Exception as err:
return jsonify({"error": str(err)}), 500