54 lines
1.5 KiB
Python
54 lines
1.5 KiB
Python
from flask import Blueprint, request, jsonify
|
|
from datetime import datetime
|
|
import geruecht.controller.userController as uc
|
|
from geruecht.decorator import login_required
|
|
from geruecht.model import MONEY, GASTRO
|
|
import time
|
|
|
|
vorstand = Blueprint("vorstand", __name__)
|
|
userController = uc.UserController()
|
|
|
|
|
|
@vorstand.route("/sm/addUser", methods=['POST', 'GET'])
|
|
@login_required(groups=[MONEY, GASTRO])
|
|
def _addUser(**kwargs):
|
|
|
|
if request.method == 'GET':
|
|
return "<h1>HEllo World</h1>"
|
|
|
|
data = request.get_json()
|
|
user = data['user']
|
|
day = data['day']
|
|
month = data['month']
|
|
year = data['year']
|
|
date = datetime(year,month,day,12)
|
|
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()
|
|
day = data['day']
|
|
month = data['month']
|
|
year = data['year']
|
|
date = datetime(year, month, day, 12)
|
|
retVal = {
|
|
'worker': userController.getWorker(date),
|
|
'day': userController.getLockedDay(date)
|
|
}
|
|
print(retVal)
|
|
return jsonify(retVal)
|
|
|
|
@vorstand.route("/sm/deleteUser", methods=['POST'])
|
|
@login_required(groups=[MONEY, GASTRO])
|
|
def _deletUser(**kwargs):
|
|
data = request.get_json()
|
|
user = data['user']
|
|
day = data['day']
|
|
month = data['month']
|
|
year = data['year']
|
|
date = datetime(year, month, day, 12)
|
|
userController.deleteWorker(user['username'], date)
|
|
return jsonify({"ok": "ok"}) |