Set location on role

merge-requests/30/head
Bob Mottram 2021-05-17 10:28:15 +01:00
parent 3dc34bd77d
commit a9740565ca
2 changed files with 21 additions and 3 deletions

View File

@ -619,14 +619,27 @@ def personUpgradeActor(baseDir: str, personJson: {},
{ {
'@type': 'Occupation', '@type': 'Occupation',
'name': occupationName, 'name': occupationName,
"location": { 'location': {
"@type": "VirtualLocation", '@type': 'VirtualLocation',
"url": personDomain 'url': personDomain
}, },
'skills': [] 'skills': []
} }
] ]
updateActor = True updateActor = True
else:
# add location if it is missing
for index in range(len(personJson['hasOccupation'])):
ocItem = personJson['hasOccupation'][index]
if ocItem.get('hasOccupation'):
ocItem = ocItem['hasOccupation']
if not ocItem.get('location'):
personDomain = personJson['id'].split('/users/')[0]
ocItem['location'] = {
"@type": "VirtualLocation",
"url": personDomain
}
updateActor = True
# if no roles are defined then ensure that the admin # if no roles are defined then ensure that the admin
# roles are configured # roles are configured

View File

@ -140,11 +140,16 @@ def _setActorRole(actorJson: {}, roleName: str) -> bool:
if occupationItem['hasOccupation']['name'] == roleName: if occupationItem['hasOccupation']['name'] == roleName:
return True return True
statusNumber, published = getStatusNumber() statusNumber, published = getStatusNumber()
actorDomain = actorJson['id'].split('/users/')[0]
newRole = { newRole = {
"@type": "Role", "@type": "Role",
"hasOccupation": { "hasOccupation": {
"@type": "Occupation", "@type": "Occupation",
"name": roleName, "name": roleName,
'location': {
'@type': 'VirtualLocation',
'url': actorDomain
},
"occupationalCategory": { "occupationalCategory": {
"@type": "CategoryCode", "@type": "CategoryCode",
"inCodeSet": { "inCodeSet": {