From 3dc34bd77d1c6258bf1e63ba3308d94f2e2e1855 Mon Sep 17 00:00:00 2001 From: Bob Mottram <bob@freedombone.net> Date: Mon, 17 May 2021 10:12:10 +0100 Subject: [PATCH] Set locations for roles --- person.py | 14 ++++++++++++++ skills.py | 5 +++++ tests.py | 8 ++++++++ 3 files changed, 27 insertions(+) diff --git a/person.py b/person.py index ea7b228b2..d9f407690 100644 --- a/person.py +++ b/person.py @@ -288,6 +288,10 @@ def _createPersonBase(baseDir: str, nickname: str, domain: str, port: int, { '@type': 'Occupation', 'name': "", + "location": { + "@type": "VirtualLocation", + "url": httpPrefix + '://' + domain + }, 'skills': [] } ], @@ -584,10 +588,15 @@ def personUpgradeActor(baseDir: str, personJson: {}, # if the older skills format is being used then switch # to the new one if not personJson.get('hasOccupation'): + personDomain = personJson['id'].split('/users/')[0] personJson['hasOccupation'] = [ { '@type': 'Occupation', 'name': occupationName, + "location": { + "@type": "VirtualLocation", + "url": personDomain + }, 'skills': [] } ] @@ -605,10 +614,15 @@ def personUpgradeActor(baseDir: str, personJson: {}, updateActor = True if not isinstance(personJson['hasOccupation'], list): + personDomain = personJson['id'].split('/users/')[0] personJson['hasOccupation'] = [ { '@type': 'Occupation', 'name': occupationName, + "location": { + "@type": "VirtualLocation", + "url": personDomain + }, 'skills': [] } ] diff --git a/skills.py b/skills.py index c97c678fd..f55e4b8fe 100644 --- a/skills.py +++ b/skills.py @@ -82,10 +82,15 @@ def setActorSkillLevel(actorJson: {}, if not actorJson: return True if not actorJson.get('hasOccupation'): + actorDomain = actorJson['id'].split('/users/')[0] actorJson['hasOccupation'] = [ { '@type': 'Occupation', 'name': '', + "location": { + "@type": "VirtualLocation", + "url": actorDomain + }, 'skills': [] } ] diff --git a/tests.py b/tests.py index 5b22e7860..8d95bef52 100644 --- a/tests.py +++ b/tests.py @@ -3666,6 +3666,10 @@ def testSkills() -> None: { '@type': 'Occupation', 'name': "Sysop", + "location": { + "@type": "VirtualLocation", + "url": "https://jazzy.hedgehog" + }, 'skills': [] } ] @@ -3688,6 +3692,10 @@ def testRoles() -> None: { '@type': 'Occupation', 'name': "Sysop", + "location": { + "@type": "VirtualLocation", + "url": "https://mostly.giraffe" + }, 'skills': [] } ]