diff --git a/geruecht/controller/databaseController.py b/geruecht/controller/databaseController.py index ae62453..3666374 100644 --- a/geruecht/controller/databaseController.py +++ b/geruecht/controller/databaseController.py @@ -56,10 +56,12 @@ class DatabaseController(metaclass=Singleton): def _convertGroupToString(self, groups): retVal = '' - for group in groups: - if len(retVal) != 0: - retVal += ',' - retVal += group + print('groups: {}'.format(groups)) + if groups: + for group in groups: + if len(retVal) != 0: + retVal += ',' + retVal += group return 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) diff --git a/geruecht/controller/ldapController.py b/geruecht/controller/ldapController.py index 40c95b3..1356c45 100644 --- a/geruecht/controller/ldapController.py +++ b/geruecht/controller/ldapController.py @@ -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 = [] diff --git a/geruecht/user/routes.py b/geruecht/user/routes.py index 23958ce..139a96a 100644 --- a/geruecht/user/routes.py +++ b/geruecht/user/routes.py @@ -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__) @@ -48,4 +49,28 @@ def _saveConfig(**kwargs): retVal['creditList'] = {credit.year: credit.toJSON() for credit in accToken.user.geruechte} return jsonify(retVal) except Exception as err: - return jsonify({"error": err}), 409 \ No newline at end of file + 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 \ No newline at end of file