From 2cf5ec245313eeee40f373bfd25e7fe381f17fe9 Mon Sep 17 00:00:00 2001 From: yashlamba Date: Tue, 17 Dec 2024 10:53:45 +0100 Subject: [PATCH] curation: add community name acronym check --- site/zenodo_rdm/curation/config.py | 3 +++ site/zenodo_rdm/curation/rules.py | 21 +++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/site/zenodo_rdm/curation/config.py b/site/zenodo_rdm/curation/config.py index eeeaa97e..9b3db292 100644 --- a/site/zenodo_rdm/curation/config.py +++ b/site/zenodo_rdm/curation/config.py @@ -13,6 +13,7 @@ award_acronym_in_additional_description, award_acronym_in_description, award_acronym_in_title, + community_name_award_acronym, contains_high_conf_keywords, contains_low_conf_keywords, eu_community_declined_request, @@ -35,6 +36,7 @@ "award_acronym_in_additional_description": award_acronym_in_additional_description, "eu_community_declined_request": eu_community_declined_request, "eu_subcommunity_declined_request": eu_subcommunity_declined_request, + "community_name_award_acronym": community_name_award_acronym, } """Rules to run for EU Curation.""" @@ -51,6 +53,7 @@ "award_acronym_in_additional_description": 0, "eu_community_declined_request": False, "eu_subcommunity_declined_request": False, + "community_name_award_acronym": 0, } """Rule scores for EU Curation (bool value implies direct approval/decline).""" diff --git a/site/zenodo_rdm/curation/rules.py b/site/zenodo_rdm/curation/rules.py index 487e66ff..0ab05391 100644 --- a/site/zenodo_rdm/curation/rules.py +++ b/site/zenodo_rdm/curation/rules.py @@ -225,3 +225,24 @@ def eu_subcommunity_declined_request(record): if result["status"] == "declined": return True return False + + +def community_name_award_acronym(record): + """Check if award acronym in community name.""" + comm_text = "" + for comm in record.parent.communities: + comm_text += comm.metadata.get("title", "") + comm_text += comm.metadata.get("page", "") + + if comm_text: + award_service = current_service_registry.get("awards") + funding = record.metadata.get("funding", []) + for f in funding: + if f["funder"].get("id") == "00k4n6c32": + if award_id := f.get("award", {}).get("id"): + award = award_service.record_cls.pid.resolve(award_id) + if award.get("acronym") and ( + award.get("acronym").lower() in comm_text.lower() + ): + return True + return False