Skip to content

Commit

Permalink
[ENG-5907] suggest affiliation for preprints
Browse files Browse the repository at this point in the history
(when feature flag PREPRINT_AFFILIATIONS is up)
  • Loading branch information
aaxelb committed Dec 5, 2024
1 parent c85fb0d commit 7287509
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
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

0 comments on commit 7287509

Please sign in to comment.