From 77931a48c6fe5683d191c35d5f9035a16fb40794 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Gr=C3=B6ger?= Date: Sun, 23 Feb 2020 11:18:54 +0100 Subject: [PATCH] finished ##188 for sm only send year, month, day. But you have to decrement month to send, because month starts with 0. Also you have to increment month to get. --- geruecht/controller/databaseController.py | 4 ++-- geruecht/user/routes.py | 5 ++++- geruecht/vorstand/routes.py | 15 ++++++++++++--- 3 files changed, 18 insertions(+), 6 deletions(-) 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