from flask import Blueprint, request, jsonify from datetime import datetime import geruecht.controller.userController as uc import geruecht.controller.ldapController as lc from geruecht.decorator import login_required from geruecht.model import MONEY, GASTRO, VORSTAND import time vorstand = Blueprint("vorstand", __name__) userController = uc.UserController() ldap= lc.LDAPController() @vorstand.route('/um/setStatus', methods=['POST']) @login_required(groups=[MONEY, GASTRO, VORSTAND]) def _setStatus(**kwargs): try: data = request.get_json() name = data['name'] retVal = userController.setStatus(name) return jsonify(retVal) except Exception as err: return jsonify({"error": str(err)}), 500 @vorstand.route('/um/updateStatus', methods=['POST']) @login_required(groups=[MONEY, GASTRO, VORSTAND]) def _updateStatus(**kwargs): try: data = request.get_json() retVal = userController.updateStatus(data) return jsonify(retVal) except Exception as err: return jsonify({"error": str(err)}), 500 @vorstand.route('/um/deleteStatus', methods=['POST']) @login_required(groups=[MONEY, GASTRO, VORSTAND]) def _deleteStatus(**kwargs): try: data = request.get_json() userController.deleteStatus(data) return jsonify({"ok": "ok"}) except Exception as err: return jsonify({"error": str(err)}), 409 @vorstand.route('/um/updateStatusUser', methods=['POST']) @login_required(groups=[MONEY, GASTRO, VORSTAND]) def _updateStatusUser(**kwargs): try: data = request.get_json() username = data['username'] status = data['status'] retVal = userController.updateStatusOfUser(username, status).toJSON() return jsonify(retVal) except Exception as err: return jsonify({"error": str(err)}), 500 @vorstand.route('/um/updateVoting', methods=['POST']) @login_required(groups=[MONEY, GASTRO, VORSTAND]) def _updateVoting(**kwargs): try: data = request.get_json() username = data['username'] voting = data['voting'] retVal = userController.updateVotingOfUser(username, voting).toJSON() return jsonify(retVal) except Exception as err: return jsonify({"error": str(err)}), 500 @vorstand.route("/sm/addUser", methods=['POST', 'GET']) @login_required(groups=[MONEY, GASTRO, VORSTAND]) def _addUser(**kwargs): if request.method == 'GET': return "