first usable site
only 2 groups exists: bar and finanzer person can be in more than 1 group site for baruser first try with autocomplete from ldap site for finanzer ; overview; specialview for 1 Person
This commit is contained in:
parent
19ff9db9df
commit
d0f665cc8b
|
@ -64,6 +64,12 @@ def _baradd():
|
|||
amount = int(data['amount'])
|
||||
|
||||
user = db.getUser(userID)
|
||||
if user is None:
|
||||
groups = ldap.getGroup(userID)
|
||||
user_data = ldap.getUserData(userID)
|
||||
user_data['group'] = groups
|
||||
db.insertUser(user_data)
|
||||
user = db.getUser(userID)
|
||||
month = user.addAmount(amount)
|
||||
|
||||
amount = abs(month[0] - month[1])
|
||||
|
@ -87,11 +93,7 @@ def _getUsers():
|
|||
|
||||
retVal = {}
|
||||
if accToken is not None:
|
||||
users = db.getAllUser()
|
||||
for user in users:
|
||||
month = user.getGeruecht().getMonth()
|
||||
if month == 0:
|
||||
retVal[user.cn] = {user.toJSON()}
|
||||
retVal = ldap.getAllUser()
|
||||
return jsonify(retVal)
|
||||
return jsonify({"error": "permission denied"}), 401
|
||||
|
||||
|
|
|
@ -106,7 +106,7 @@ class DatabaseController(metaclass=Singleton):
|
|||
self.db.close()
|
||||
raise err
|
||||
if len(data) == 1:
|
||||
return CreditList(data[0])
|
||||
return [CreditList(data[0])]
|
||||
else:
|
||||
return [CreditList(value) for value in data]
|
||||
|
||||
|
|
|
@ -63,33 +63,58 @@ class LDAPController(metaclass=Singleton):
|
|||
def __isUserInList(self, list, username):
|
||||
help_list = []
|
||||
for user in list:
|
||||
help_list.append(user[1]['cn'][0].decode('utf-8'))
|
||||
help_list.append(user['username'])
|
||||
if username in help_list:
|
||||
return True
|
||||
return False
|
||||
|
||||
def getAllUser(self):
|
||||
self.connect()
|
||||
retVal = []
|
||||
data = self.client.search_s('ou=user,{}'.format(self.dn), ldap.SCOPE_SUBTREE, attrlist=['cn', 'givenName', 'sn'])
|
||||
for user in data:
|
||||
if 'cn' in user[1]:
|
||||
username = user[1]['cn'][0].decode('utf-8')
|
||||
firstname = user[1]['givenName'][0].decode('utf-8')
|
||||
lastname = user[1]['sn'][0].decode('utf-8')
|
||||
retVal.append({'username': username, 'firstname': firstname, 'lastname': lastname})
|
||||
return retVal
|
||||
|
||||
def searchUser(self, searchString):
|
||||
self.connect()
|
||||
|
||||
name = searchString.split(" ")
|
||||
|
||||
for i in range(len(name)):
|
||||
name[i] = "*"+name[i]+"*"
|
||||
|
||||
|
||||
print(name)
|
||||
|
||||
name_result = []
|
||||
|
||||
if len(name) == 1:
|
||||
name_result[0] = self.client.search_s('ou=user,{}'.format(self.dn), ldap.SCOPE_SUBTREE, 'givenName={}'.format(name[0]), ['cn', 'givenName', 'sn'])
|
||||
name_result[1] = self.client.search_s('ou=user,{}'.format(self.dn), ldap.SCOPE_SUBTREE, 'sn={}'.format(name[0]),['cn', 'givenName', 'sn'])
|
||||
if name[0] == "**":
|
||||
name_result.append(self.client.search_s('ou=user,{}'.format(self.dn), ldap.SCOPE_SUBTREE,
|
||||
attrlist=['cn', 'givenName', 'sn']))
|
||||
else:
|
||||
name_result[2] = self.client.search_s('ou=user,{}'.format(self.dn), ldap.SCOPE_SUBTREE,
|
||||
'givenName={}'.format(name[0]), ['cn', 'givenName', 'sn'])
|
||||
name_result[3] = self.client.search_s('ou=user,{}'.format(self.dn), ldap.SCOPE_SUBTREE, 'sn={}'.format(name[0]),
|
||||
['cn', 'givenName', 'sn'])
|
||||
name_result.append(self.client.search_s('ou=user,{}'.format(self.dn), ldap.SCOPE_SUBTREE, 'givenName={}'.format(name[0]), ['cn', 'givenName', 'sn']))
|
||||
name_result.append(self.client.search_s('ou=user,{}'.format(self.dn), ldap.SCOPE_SUBTREE, 'sn={}'.format(name[0]),['cn', 'givenName', 'sn']))
|
||||
else:
|
||||
name_result.append(self.client.search_s('ou=user,{}'.format(self.dn), ldap.SCOPE_SUBTREE,
|
||||
'givenName={}'.format(name[1]), ['cn', 'givenName', 'sn']))
|
||||
name_result.append(self.client.search_s('ou=user,{}'.format(self.dn), ldap.SCOPE_SUBTREE, 'sn={}'.format(name[1]),
|
||||
['cn', 'givenName', 'sn']))
|
||||
retVal = []
|
||||
|
||||
for user in name_result:
|
||||
for names in name_result:
|
||||
for user in names:
|
||||
if 'cn' in user[1]:
|
||||
username = user[1]['cn'][0].decode('utf-8')
|
||||
if not self.__isUserInList(retVal, username):
|
||||
firstname = user[1]['givenName'][0].decode('utf-8')
|
||||
lastname = user[1]['givenName'][0].decode('utf-8')
|
||||
retVal.append({username: username, firstname: firstname, lastname: lastname})
|
||||
lastname = user[1]['sn'][0].decode('utf-8')
|
||||
retVal.append({'username': username, 'firstname': firstname, 'lastname': lastname})
|
||||
|
||||
return retVal
|
||||
|
||||
|
|
|
@ -28,6 +28,8 @@ def _getFinanzer():
|
|||
for user in users:
|
||||
LOGGER.debug("Add User {} to ReturnValue".format(user))
|
||||
dic[user.cn] = user.toJSON()
|
||||
creditList = db.getCreditListFromUser(user)
|
||||
dic[user.cn]['creditList'] = {credit.year: credit.toJSON() for credit in creditList}
|
||||
LOGGER.debug("ReturnValue is {}".format(dic))
|
||||
LOGGER.info("Send main for Finanzer")
|
||||
return jsonify(dic)
|
||||
|
@ -130,7 +132,9 @@ def _addCredit():
|
|||
accToken = verifyAccessToken(token, MONEY)
|
||||
|
||||
if accToken is not None:
|
||||
|
||||
data = request.get_json()
|
||||
print(data)
|
||||
LOGGER.debug("Get data {}".format(data))
|
||||
userID = data['userId']
|
||||
credit = int(data['credit'])
|
||||
|
|
|
@ -321,6 +321,7 @@ class CreditList():
|
|||
"dez": {
|
||||
"credit": self.dez_guthaben,
|
||||
"depts": self.dez_schulden},
|
||||
"last": self.last_schulden
|
||||
}
|
||||
return dic
|
||||
|
||||
|
|
|
@ -40,6 +40,7 @@ class User():
|
|||
self.geruechte = geruechte
|
||||
elif type(geruechte) == CreditList:
|
||||
self.geruechte.append(geruechte)
|
||||
self.updateGeruecht()
|
||||
#geruechte = db.relationship('CreditList', backref='user', lazy=True)
|
||||
|
||||
def createGeruecht(self, amount=0, year=datetime.now().year):
|
||||
|
|
Loading…
Reference in New Issue