diff --git a/geruecht/controller/databaseController.py b/geruecht/controller/databaseController.py index 3666374..fe84080 100644 --- a/geruecht/controller/databaseController.py +++ b/geruecht/controller/databaseController.py @@ -132,14 +132,14 @@ class DatabaseController(metaclass=Singleton): cursor = self.db.connection.cursor() cursor.execute("select * from bardienste where user_id={} and startdatetime='{}'".format(user.id, date)) data = cursor.fetchone() - return {"user": user.toJSON(), "startdatetime": data['startdatetime'], "enddatetime": data['enddatetime']} if data else None + return {"user": user.toJSON(), "startdatetime": data['startdatetime'], "enddatetime": data['enddatetime'], "start": { "year": data['startdatetime'].year, "month": data['startdatetime'].month, "day": data['startdatetime'].day}} if data else None def getWorkers(self, date): cursor = self.db.connection.cursor() cursor.execute("select * from bardienste where startdatetime='{}'".format(date)) data = cursor.fetchall() - return [{"user": self.getUserById(work['user_id']).toJSON(), "startdatetime": work['startdatetime'], "enddatetime": work['enddatetime']} for work in data] + return [{"user": self.getUserById(work['user_id']).toJSON(), "startdatetime": work['startdatetime'], "enddatetime": work['enddatetime'], "start": { "year": work['startdatetime'].year, "month": work['startdatetime'].month, "day": work['startdatetime'].day}} for work in data] def setWorker(self, user, date): diff --git a/geruecht/user/routes.py b/geruecht/user/routes.py index 11cb669..b1af021 100644 --- a/geruecht/user/routes.py +++ b/geruecht/user/routes.py @@ -55,7 +55,10 @@ def _saveConfig(**kwargs): @login_required(groups=[USER]) def _getUser(**kwargs): data = request.get_json() - date = datetime.utcfromtimestamp(int(data['date'])) + day = data['day'] + month = data['month'] + year = data['year'] + date = datetime(year, month, day, 12) retVal = userController.getWorker(date) print(retVal) return jsonify(retVal) \ No newline at end of file diff --git a/geruecht/vorstand/routes.py b/geruecht/vorstand/routes.py index 35e375b..a420330 100644 --- a/geruecht/vorstand/routes.py +++ b/geruecht/vorstand/routes.py @@ -18,7 +18,10 @@ def _addUser(**kwargs): data = request.get_json() user = data['user'] - date = datetime.utcfromtimestamp(int(data['date'])) + 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) @@ -27,7 +30,10 @@ def _addUser(**kwargs): @login_required(groups=[MONEY, GASTRO]) def _getUser(**kwargs): data = request.get_json() - date = datetime.utcfromtimestamp(int(data['date'])) + day = data['day'] + month = data['month'] + year = data['year'] + date = datetime(year, month, day, 12) retVal = userController.getWorker(date) print(retVal) return jsonify(retVal) @@ -37,6 +43,9 @@ def _getUser(**kwargs): def _deletUser(**kwargs): data = request.get_json() user = data['user'] - date = datetime.utcfromtimestamp(int(data['date'])) + day = data['day'] + month = data['month'] + year = data['year'] + date = datetime(year, month, day, 12) userController.deleteWorker(user['username'], date) return jsonify({"ok": "ok"}) \ No newline at end of file