2020-01-18 22:31:49 +00:00
|
|
|
from flask import Blueprint, request, jsonify
|
|
|
|
from datetime import datetime
|
2020-01-19 08:07:45 +00:00
|
|
|
import geruecht.controller.userController as uc
|
|
|
|
from geruecht.decorator import login_required
|
2020-01-18 22:31:49 +00:00
|
|
|
from geruecht.model import MONEY, GASTRO
|
|
|
|
|
|
|
|
vorstand = Blueprint("vorstand", __name__)
|
2020-01-19 08:07:45 +00:00
|
|
|
userController = uc.UserController()
|
|
|
|
|
2020-01-18 22:31:49 +00:00
|
|
|
|
|
|
|
@vorstand.route("/sm/addUser", methods=['POST', 'GET'])
|
2020-01-19 08:07:45 +00:00
|
|
|
@login_required(groups=[MONEY, GASTRO])
|
2020-01-19 20:32:58 +00:00
|
|
|
def _addUser(**kwargs):
|
2020-01-18 22:31:49 +00:00
|
|
|
|
|
|
|
if request.method == 'GET':
|
|
|
|
return "<h1>HEllo World</h1>"
|
|
|
|
|
2020-01-19 08:07:45 +00:00
|
|
|
data = request.get_json()
|
|
|
|
user = data['user']
|
|
|
|
date = datetime.utcfromtimestamp(int(data['date']))
|
2020-01-19 20:32:58 +00:00
|
|
|
retVal = userController.addWorker(user['username'], date)
|
|
|
|
print(retVal)
|
|
|
|
return jsonify(retVal)
|
|
|
|
|
|
|
|
@vorstand.route("/sm/getUser", methods=['POST'])
|
|
|
|
@login_required(groups=[MONEY, GASTRO])
|
|
|
|
def _getUser(**kwargs):
|
|
|
|
data = request.get_json()
|
|
|
|
date = datetime.utcfromtimestamp(int(data['date']))
|
|
|
|
retVal = userController.getWorker(date)
|
|
|
|
print(retVal)
|
|
|
|
return jsonify(retVal)
|
2020-01-18 22:31:49 +00:00
|
|
|
|
2020-01-19 20:32:58 +00:00
|
|
|
@vorstand.route("/sm/deleteUser", methods=['POST'])
|
|
|
|
@login_required(groups=[MONEY, GASTRO])
|
|
|
|
def _deletUser(**kwargs):
|
|
|
|
data = request.get_json()
|
|
|
|
user = data['user']
|
|
|
|
date = datetime.utcfromtimestamp(int(data['date']))
|
|
|
|
userController.deleteWorker(user['username'], date)
|
|
|
|
return jsonify({"ok": "ok"})
|