Skip to content

Commit

Permalink
fix: add missing metadata for registration components
Browse files Browse the repository at this point in the history
if license (`dcterms:rights`) is missing on a node, inherit from parent

registration components inherit their registration template/schema
(`dcterms:conformsTo`) from the root (where responses are stored)
  • Loading branch information
aaxelb committed Aug 22, 2023
1 parent a81b476 commit d094ec0
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions osf/metadata/osf_gathering.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,12 +435,20 @@ def gather_preprint_withdrawal(focus):

@gather.er(DCTERMS.dateCopyrighted, DCTERMS.rightsHolder, DCTERMS.rights)
def gather_licensing(focus):
yield from _rights_for_item(focus.dbmodel)


def _rights_for_item(item):
license_record = (
focus.dbmodel.license
if focus.rdftype == OSF.Preprint
else getattr(focus.dbmodel, 'node_license', None)
item.license
if isinstance(item, osfdb.Preprint)
else getattr(item, 'node_license', None)
)
if license_record is not None:
if license_record is None:
_parent = getattr(item, 'parent', None)
if _parent:
yield from _rights_for_item(_parent)
else:
yield (DCTERMS.dateCopyrighted, license_record.year)
for copyright_holder in license_record.copyright_holders:
yield (DCTERMS.rightsHolder, copyright_holder)
Expand Down Expand Up @@ -887,7 +895,7 @@ def gather_ia_url(focus):
focustype_iris=[OSF.Registration]
)
def gather_registration_type(focus):
_reg_schema = getattr(focus.dbmodel, 'registration_schema')
_reg_schema = getattr(focus.dbmodel.root, 'registration_schema')
if _reg_schema:
_schema_url = rdflib.URIRef(_reg_schema.absolute_api_v2_url)
yield (DCTERMS.conformsTo, _schema_url)
Expand Down

0 comments on commit d094ec0

Please sign in to comment.