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.
This commit is contained in:
Tim Gröger 2020-02-23 11:18:54 +01:00
parent e3bf18a927
commit 77931a48c6
3 changed files with 18 additions and 6 deletions

View File

@ -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):

View File

@ -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)

View File

@ -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"})