VForWaTer / metacatalog

Modular metadata management platform for environmental data.
https://vforwater.github.io/metacatalog
GNU General Public License v3.0
3 stars 1 forks source link

`Entry.contributors` returns `PersonAssociations` instead of `Person` #249

Closed mmaelicke closed 1 year ago

mmaelicke commented 1 year ago

I just found out that, Entry.contributors stills returns PersonAssociations instead of Person objects: Bildschirmfoto vom 2023-01-31 14-16-16

Originally posted by @AlexDo1 in https://github.com/VForWaTer/metacatalog/issues/248#issuecomment-1410333968

mmaelicke commented 1 year ago

Should be solvable similar to the solution in #244, which fixed #236

mmaelicke commented 1 year ago

@AlexDo1 I would close this without implementing it, as this is actually not a bug. The PersonAssociation further relates the PersonRoles. If we directly load the Person, we loose the information on the role with which the person is related to the Entry.

However, accessing the persons is trivial:

[pa.person for pa in entry.contributors]

returns a list Persons. A drawback is, that the PersonAssociation.to_dict method always includes the Entry. We could change that to only inlcude the Entry if deep=True. Then this code would produce better output:

[pa.to_dict() for pa in entry.contributors]
[{
  "person": `Person`,
  "role": `PersonRole`,
  "order": `Number`
}]
AlexDo1 commented 1 year ago

Yes that's good.

The fact Persons are still easily accessible through PersonAssociation.person solves the issue for me.

The changes to PersonAssociation.to_dict to only include the Entry with deep=True would still be nice..