add new route for user, so he can see, when he has jobs
This commit is contained in:
parent
ca1f2259c5
commit
3dca45f12e
|
@ -56,6 +56,8 @@ class DatabaseController(metaclass=Singleton):
|
|||
|
||||
def _convertGroupToString(self, groups):
|
||||
retVal = ''
|
||||
print('groups: {}'.format(groups))
|
||||
if groups:
|
||||
for group in groups:
|
||||
if len(retVal) != 0:
|
||||
retVal += ','
|
||||
|
@ -73,6 +75,7 @@ class DatabaseController(metaclass=Singleton):
|
|||
|
||||
def updateUser(self, user):
|
||||
cursor = self.db.connection.cursor()
|
||||
print('uid: {}; group: {}'.format(user.uid, user.group))
|
||||
groups = self._convertGroupToString(user.group)
|
||||
sql = "update user set dn='{}', firstname='{}', lastname='{}', gruppe='{}', lockLimit={}, locked={}, autoLock={}, mail='{}' where uid='{}'".format(
|
||||
user.dn, user.firstname, user.lastname, groups, user.limit, user.locked, user.autoLock, user.mail, user.uid)
|
||||
|
|
|
@ -69,7 +69,7 @@ class LDAPController(metaclass=Singleton):
|
|||
retVal.append(BAR)
|
||||
return retVal
|
||||
except Exception as err:
|
||||
traceback.print_exception(err)
|
||||
traceback.print_exc()
|
||||
|
||||
def __isUserInList(self, list, username):
|
||||
help_list = []
|
||||
|
|
|
@ -4,6 +4,7 @@ import geruecht.controller.userController as uc
|
|||
from geruecht.model import USER
|
||||
from datetime import datetime
|
||||
import time
|
||||
import traceback
|
||||
|
||||
user = Blueprint("user", __name__)
|
||||
|
||||
|
@ -49,3 +50,27 @@ def _saveConfig(**kwargs):
|
|||
return jsonify(retVal)
|
||||
except Exception as err:
|
||||
return jsonify({"error": err}), 409
|
||||
|
||||
@user.route("/user/job", methods=['POST'])
|
||||
@login_required(groups=[USER])
|
||||
def _getJob(**kwargs):
|
||||
try:
|
||||
if 'accToken' in kwargs:
|
||||
accToken = kwargs['accToken']
|
||||
data = request.get_json()
|
||||
date = datetime.utcfromtimestamp(int(data['date']))
|
||||
test = userController.getWorker(date, username=accToken.user.uid)
|
||||
if test == [None]:
|
||||
job = False
|
||||
else:
|
||||
job = True
|
||||
if job:
|
||||
workers = userController.getWorker(date)
|
||||
for worker in workers:
|
||||
if worker['user']['uid'] == accToken.user.uid:
|
||||
workers.remove(worker)
|
||||
return jsonify({'job': job, 'workers': workers})
|
||||
return jsonify({'job': job})
|
||||
except Exception as err:
|
||||
traceback.print_exc()
|
||||
return jsonify({"error": str(err)}), 409
|
Loading…
Reference in New Issue