mirror of https://gitlab.com/bashrc2/epicyon
Change function name
parent
ef5b5d7869
commit
4e354c344f
16
roles.py
16
roles.py
|
@ -33,7 +33,7 @@ def _clearRoleStatus(baseDir: str, role: str) -> None:
|
||||||
if not actorJson.get('affiliation'):
|
if not actorJson.get('affiliation'):
|
||||||
continue
|
continue
|
||||||
rolesList = \
|
rolesList = \
|
||||||
getRolesFromString(actorJson['affiliation']['roleName'])
|
getRolesFromList(actorJson['affiliation']['roleName'])
|
||||||
if role in rolesList:
|
if role in rolesList:
|
||||||
rolesList.remove(role)
|
rolesList.remove(role)
|
||||||
saveJson(actorJson, filename)
|
saveJson(actorJson, filename)
|
||||||
|
@ -115,15 +115,15 @@ def setRolesFromList(actorJson: {}, rolesList: []) -> None:
|
||||||
actorJson['affiliation']['roleName'] = rolesList.copy()
|
actorJson['affiliation']['roleName'] = rolesList.copy()
|
||||||
|
|
||||||
|
|
||||||
def getRolesFromString(rolesStr: str) -> []:
|
def getRolesFromList(rolesList: []) -> []:
|
||||||
"""Returns a list of roles from a string
|
"""Returns a list of roles from a list
|
||||||
"""
|
"""
|
||||||
if isinstance(rolesStr, list):
|
if isinstance(rolesList, list):
|
||||||
rolesList = rolesStr
|
rolesList2 = rolesList
|
||||||
else:
|
else:
|
||||||
rolesList = rolesStr.split(',')
|
rolesList2 = rolesList.split(',')
|
||||||
rolesResult = []
|
rolesResult = []
|
||||||
for roleName in rolesList:
|
for roleName in rolesList2:
|
||||||
rolesResult.append(roleName.strip().lower())
|
rolesResult.append(roleName.strip().lower())
|
||||||
return rolesResult
|
return rolesResult
|
||||||
|
|
||||||
|
@ -152,7 +152,7 @@ def setRole(baseDir: str, nickname: str, domain: str,
|
||||||
if not actorJson.get('affiliation'):
|
if not actorJson.get('affiliation'):
|
||||||
return False
|
return False
|
||||||
rolesList = \
|
rolesList = \
|
||||||
getRolesFromString(actorJson['affiliation']['roleName'])
|
getRolesFromList(actorJson['affiliation']['roleName'])
|
||||||
actorChanged = False
|
actorChanged = False
|
||||||
if role:
|
if role:
|
||||||
# add the role
|
# add the role
|
||||||
|
|
4
tests.py
4
tests.py
|
@ -70,7 +70,7 @@ from skills import setSkillLevel
|
||||||
from skills import setSkillsFromDict
|
from skills import setSkillsFromDict
|
||||||
from skills import getSkillsFromList
|
from skills import getSkillsFromList
|
||||||
from roles import setRolesFromList
|
from roles import setRolesFromList
|
||||||
from roles import getRolesFromString
|
from roles import getRolesFromList
|
||||||
from roles import setRole
|
from roles import setRole
|
||||||
from auth import constantTimeStringCheck
|
from auth import constantTimeStringCheck
|
||||||
from auth import createBasicAuthHeader
|
from auth import createBasicAuthHeader
|
||||||
|
@ -3696,7 +3696,7 @@ def testRoles() -> None:
|
||||||
testRolesList = ["admin", "moderator"]
|
testRolesList = ["admin", "moderator"]
|
||||||
setRolesFromList(actorJson, testRolesList)
|
setRolesFromList(actorJson, testRolesList)
|
||||||
assert actorJson['affiliation']['roleName']
|
assert actorJson['affiliation']['roleName']
|
||||||
rolesList = getRolesFromString(actorJson['affiliation']['roleName'])
|
rolesList = getRolesFromList(actorJson['affiliation']['roleName'])
|
||||||
assert 'admin' in rolesList
|
assert 'admin' in rolesList
|
||||||
assert 'moderator' in rolesList
|
assert 'moderator' in rolesList
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue