mirror of https://gitlab.com/bashrc2/epicyon
Set skill level
parent
ae6d40fe30
commit
065daedba9
18
person.py
18
person.py
|
@ -85,6 +85,22 @@ def setProfileImage(baseDir: str,httpPrefix :str,nickname: str,domain: str, \
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def setSkillLevel(baseDir: str,nickname: str,domain: str, \
|
||||||
|
skill: str,skillLevelPercent: int) -> bool:
|
||||||
|
"""Set a skill level for a person
|
||||||
|
"""
|
||||||
|
if skillLevelPercent<0 or skillLevelPercent>100:
|
||||||
|
return False
|
||||||
|
actorFilename=baseDir+'/accounts/'+nickname+'@'+domain+'.json'
|
||||||
|
if not os.path.isfile(actorFilename):
|
||||||
|
return False
|
||||||
|
with open(actorFilename, 'r') as fp:
|
||||||
|
actorJson=commentjson.load(fp)
|
||||||
|
actorJson['skills'][skill]=skillLevelPercent
|
||||||
|
with open(actorFilename, 'w') as fp:
|
||||||
|
commentjson.dump(actorJson, fp, indent=4, sort_keys=False)
|
||||||
|
return True
|
||||||
|
|
||||||
def createPersonBase(baseDir: str,nickname: str,domain: str,port: int, \
|
def createPersonBase(baseDir: str,nickname: str,domain: str,port: int, \
|
||||||
httpPrefix: str, saveToFile: bool,password=None) -> (str,str,{},{}):
|
httpPrefix: str, saveToFile: bool,password=None) -> (str,str,{},{}):
|
||||||
"""Returns the private key, public key, actor and webfinger endpoint
|
"""Returns the private key, public key, actor and webfinger endpoint
|
||||||
|
@ -123,6 +139,8 @@ def createPersonBase(baseDir: str,nickname: str,domain: str,port: int, \
|
||||||
'featured': httpPrefix+'://'+domain+'/users/'+nickname+'/collections/featured',
|
'featured': httpPrefix+'://'+domain+'/users/'+nickname+'/collections/featured',
|
||||||
'followers': httpPrefix+'://'+domain+'/users/'+nickname+'/followers',
|
'followers': httpPrefix+'://'+domain+'/users/'+nickname+'/followers',
|
||||||
'following': httpPrefix+'://'+domain+'/users/'+nickname+'/following',
|
'following': httpPrefix+'://'+domain+'/users/'+nickname+'/following',
|
||||||
|
'skills': {},
|
||||||
|
'roles': {},
|
||||||
'icon': {'mediaType': 'image/png',
|
'icon': {'mediaType': 'image/png',
|
||||||
'type': 'Image',
|
'type': 'Image',
|
||||||
'url': httpPrefix+'://'+domain+'/users/'+nickname+'/icon.png'},
|
'url': httpPrefix+'://'+domain+'/users/'+nickname+'/icon.png'},
|
||||||
|
|
2
tests.py
2
tests.py
|
@ -40,6 +40,7 @@ from follow import sendFollowRequest
|
||||||
from person import createPerson
|
from person import createPerson
|
||||||
from person import setPreferredNickname
|
from person import setPreferredNickname
|
||||||
from person import setBio
|
from person import setBio
|
||||||
|
from person import setSkillLevel
|
||||||
from auth import createBasicAuthHeader
|
from auth import createBasicAuthHeader
|
||||||
from auth import authorizeBasic
|
from auth import authorizeBasic
|
||||||
from auth import storeBasicCredentials
|
from auth import storeBasicCredentials
|
||||||
|
@ -147,6 +148,7 @@ def createServerAlice(path: str,domain: str,port: int,federationList: [], \
|
||||||
createPerson(path,nickname,domain,port,httpPrefix,True,password)
|
createPerson(path,nickname,domain,port,httpPrefix,True,password)
|
||||||
deleteAllPosts(path,nickname,domain,'inbox')
|
deleteAllPosts(path,nickname,domain,'inbox')
|
||||||
deleteAllPosts(path,nickname,domain,'outbox')
|
deleteAllPosts(path,nickname,domain,'outbox')
|
||||||
|
assert setSkillLevel(path,nickname,domain,'hacking',90)
|
||||||
if hasFollows:
|
if hasFollows:
|
||||||
followPerson(path,nickname,domain,'bob','127.0.0.100:61936', \
|
followPerson(path,nickname,domain,'bob','127.0.0.100:61936', \
|
||||||
federationList,True)
|
federationList,True)
|
||||||
|
|
Loading…
Reference in New Issue