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'):
|
||||
continue
|
||||
rolesList = \
|
||||
getRolesFromString(actorJson['affiliation']['roleName'])
|
||||
getRolesFromList(actorJson['affiliation']['roleName'])
|
||||
if role in rolesList:
|
||||
rolesList.remove(role)
|
||||
saveJson(actorJson, filename)
|
||||
|
@ -115,15 +115,15 @@ def setRolesFromList(actorJson: {}, rolesList: []) -> None:
|
|||
actorJson['affiliation']['roleName'] = rolesList.copy()
|
||||
|
||||
|
||||
def getRolesFromString(rolesStr: str) -> []:
|
||||
"""Returns a list of roles from a string
|
||||
def getRolesFromList(rolesList: []) -> []:
|
||||
"""Returns a list of roles from a list
|
||||
"""
|
||||
if isinstance(rolesStr, list):
|
||||
rolesList = rolesStr
|
||||
if isinstance(rolesList, list):
|
||||
rolesList2 = rolesList
|
||||
else:
|
||||
rolesList = rolesStr.split(',')
|
||||
rolesList2 = rolesList.split(',')
|
||||
rolesResult = []
|
||||
for roleName in rolesList:
|
||||
for roleName in rolesList2:
|
||||
rolesResult.append(roleName.strip().lower())
|
||||
return rolesResult
|
||||
|
||||
|
@ -152,7 +152,7 @@ def setRole(baseDir: str, nickname: str, domain: str,
|
|||
if not actorJson.get('affiliation'):
|
||||
return False
|
||||
rolesList = \
|
||||
getRolesFromString(actorJson['affiliation']['roleName'])
|
||||
getRolesFromList(actorJson['affiliation']['roleName'])
|
||||
actorChanged = False
|
||||
if 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 getSkillsFromList
|
||||
from roles import setRolesFromList
|
||||
from roles import getRolesFromString
|
||||
from roles import getRolesFromList
|
||||
from roles import setRole
|
||||
from auth import constantTimeStringCheck
|
||||
from auth import createBasicAuthHeader
|
||||
|
@ -3696,7 +3696,7 @@ def testRoles() -> None:
|
|||
testRolesList = ["admin", "moderator"]
|
||||
setRolesFromList(actorJson, testRolesList)
|
||||
assert actorJson['affiliation']['roleName']
|
||||
rolesList = getRolesFromString(actorJson['affiliation']['roleName'])
|
||||
rolesList = getRolesFromList(actorJson['affiliation']['roleName'])
|
||||
assert 'admin' in rolesList
|
||||
assert 'moderator' in rolesList
|
||||
|
||||
|
|
Loading…
Reference in New Issue