77from database .model .agent .contact import Contact
88from database .model .agent .expertise import Expertise
99from database .model .agent .language import Language
10+ from database .model .agent .organisation import Organisation
1011from database .model .concept .aiod_entry import AIoDEntryORM
1112from database .model .field_length import NORMAL
1213from database .model .helper_functions import many_to_many_link_factory
@@ -50,11 +51,14 @@ class Person(PersonBase, Agent, table=True): # type: ignore [call-arg]
5051 expertise : list [Expertise ] = Relationship (
5152 link_model = many_to_many_link_factory ("person" , Expertise .__tablename__ )
5253 )
53- language : list [Language ] = Relationship (
54+ languages : list [Language ] = Relationship (
5455 link_model = many_to_many_link_factory ("person" , Language .__tablename__ )
5556 )
5657 contact_details : Optional [Contact ] = Relationship (sa_relationship_kwargs = {"uselist" : False })
57- # TODO(jos): memberOf? This should probably be on Agent
58+
59+ member_of : list [Organisation ] = Relationship (
60+ link_model = many_to_many_link_factory ("person" , Organisation .__tablename__ )
61+ )
5862
5963 class RelationshipConfig (Agent .RelationshipConfig ):
6064 contact_details : int | None = OneToOne (
@@ -70,14 +74,22 @@ class RelationshipConfig(Agent.RelationshipConfig):
7074 default_factory_pydantic = list ,
7175 on_delete_trigger_orphan_deletion = list ,
7276 )
73- language : list [str ] = ManyToMany (
77+ languages : list [str ] = ManyToMany (
7478 description = "A language this person masters, in ISO639-3" ,
7579 _serializer = AttributeSerializer ("name" ),
7680 deserializer = FindByNameDeserializerList (Language ),
7781 example = ["eng" , "fra" , "spa" ],
7882 default_factory_pydantic = list ,
7983 )
8084
85+ member_of : list [int ] = ManyToMany (
86+ description = "The list of Organisations that a Person affiliates with." ,
87+ _serializer = AttributeSerializer ("identifier" ),
88+ deserializer = FindByIdentifierDeserializerList (Organisation ),
89+ example = [],
90+ default_factory_pydantic = list ,
91+ )
92+
8193
8294deserializer_list = FindByIdentifierDeserializerList (Person )
8395AIoDEntryORM .RelationshipConfig .editor .deserializer = deserializer_list # type: ignore
0 commit comments