Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ENG-5907] osfmap: suggest affiliation for preprints #837

Merged
merged 1 commit into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions share/models/feature_flag.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class FeatureFlag(models.Model):
SUGGEST_CREATOR_FACET = 'suggest_creator_facet'
FORBID_UNTRUSTED_FEED = 'forbid_untrusted_feed'
TROVESEARCH_DENORMILY = 'trovesearch_denormily'
PREPRINT_AFFILIATIONS = 'preprint_affiliations'

# name _should_ be one of the constants above, but that is not enforced by `choices`
name = models.TextField(unique=True)
Expand Down
10 changes: 9 additions & 1 deletion trove/vocab/osfmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -851,7 +851,7 @@ def osfmap_shorthand() -> IriShorthand:
(DCTERMS.subject,),
(DCTERMS.rights,),
(DCTERMS.publisher,),
(DCTERMS.creator, OSFMAP.affiliation),
(OSFMAP.affiliation,),
(OSFMAP.hasDataResource,),
(OSFMAP.hasPreregisteredAnalysisPlan,),
(OSFMAP.hasPreregisteredStudyDesign,),
Expand Down Expand Up @@ -906,6 +906,14 @@ def suggested_property_paths(type_iris: set[str]) -> tuple[tuple[str, ...], ...]
_suggested = AGENT_SUGGESTED_PROPERTY_PATHS
elif type_iris == {OSFMAP.Preprint}:
_suggested = PREPRINT_SUGGESTED_PROPERTY_PATHS
if not FeatureFlag.objects.flag_is_up(FeatureFlag.PREPRINT_AFFILIATIONS):
# replace `affilation` with `creator.affiliation`
_no = (OSFMAP.affiliation,)
_instead = (DCTERMS.creator, OSFMAP.affiliation)
_suggested = tuple(
(_instead if (_path == _no) else _path)
for _path in _suggested
)
elif type_iris == {OSFMAP.File}:
_suggested = FILE_SUGGESTED_PROPERTY_PATHS
elif type_iris <= {OSFMAP.Project, OSFMAP.ProjectComponent}:
Expand Down
Loading