Skip to content
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
4 changes: 2 additions & 2 deletions invenio.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ from invenio_app_rdm.config import \
from invenio_app_rdm.config import \
VOCABULARIES_DATASTREAM_WRITERS as DEFAULT_VOCABULARIES_DATASTREAM_WRITERS
from cds_rdm.clc_sync.services.components import ClcSyncComponent
from cds_rdm.components import CDSResourcePublication, CommitteeApprovalComponent, MintAlternateIdentifierComponent, PublicationInclusionComponent, SubjectsValidationComponent
from cds_rdm.components import CDSResourcePublication, CommitteeApprovalComponent, MintAlternateIdentifierComponent, SubjectsValidationComponent # PublicationInclusionComponent temporarily disabled
from cds_rdm.pids import validate_optional_doi_transitions
from cds_rdm.views import frontpage_view_function, inspire_link_render
from cds_rdm.reviews.policy import CDSRecordVersionReviewPolicy
Expand Down Expand Up @@ -761,7 +761,7 @@ RDM_RECORDS_SERVICE_COMPONENTS = [
CDSResourcePublication,
ClcSyncComponent,
MintAlternateIdentifierComponent,
PublicationInclusionComponent,
# PublicationInclusionComponent, # temporarily disabled
VCSComponent,
]

Expand Down
113 changes: 58 additions & 55 deletions site/cds_rdm/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
from invenio_records_resources.services.uow import TaskOp
from marshmallow import ValidationError

from .tasks import submit_community_inclusion_request, sync_alternate_identifiers
from .tasks import (
sync_alternate_identifiers, # submit_community_inclusion_request temporarily disabled
)


def is_record_public(record):
Expand Down Expand Up @@ -356,57 +358,58 @@ def publish(self, identity, draft=None, record=None):
)


class PublicationInclusionComponent(ServiceComponent):
"""Auto-submit a community inclusion request to the CERN Scientific Community.

Triggers on publish for public records whose resource type is listed in
`CDS_CERN_SCIENTIFIC_RESOURCE_TYPES`. The request is created asynchronously
after the publish transaction commits.
"""

def _is_eligible(self, draft, record):
"""Return True when the record should be auto-submitted for community inclusion."""
if not is_record_public(draft):
return False

resource_type = draft["metadata"]["resource_type"]["id"]
research_resource_types = current_app.config.get(
"CDS_CERN_SCIENTIFIC_RESOURCE_TYPES", set()
)
if resource_type not in research_resource_types:
return False

# Skip if the record is in the Scientific Community or the Related Research Community already
# IMPORTANT:
# 1. For thesis, we have the component CDSResourcePublication to validate the community selection
# 2. For other resource types, it is highly unlikely that the record is NOT eligible for inclusion
# in the CERN Research Community, since these works typically belong to CERN
# On the off chance if there is a rare case, it will be dealt via support on case by case basis
communities_to_skip = [
current_app.config["CDS_CERN_SCIENTIFIC_COMMUNITY_ID"],
current_app.config["CDS_CERN_RELATED_RESEARCH_COMMUNITY_ID"],
]
for community_id in communities_to_skip:
if not community_id:
current_app.logger.error(
f"Scientific Community IDs are not configured; "
"skipping auto community inclusion for record %s.",
record.pid.pid_value,
)
return False
if community_id in record.parent.communities.ids:
return False

return True

def publish(self, identity, draft=None, record=None, **kwargs):
"""Schedule community inclusion request after the record is published."""
if not self._is_eligible(draft, record):
return

self.uow.register(
TaskOp(
submit_community_inclusion_request,
record_id=record.pid.pid_value,
)
)
# PublicationInclusionComponent temporarily disabled
# class PublicationInclusionComponent(ServiceComponent):
# """Auto-submit a community inclusion request to the CERN Scientific Community.
#
# Triggers on publish for public records whose resource type is listed in
# `CDS_CERN_SCIENTIFIC_RESOURCE_TYPES`. The request is created asynchronously
# after the publish transaction commits.
# """
#
# def _is_eligible(self, draft, record):
# """Return True when the record should be auto-submitted for community inclusion."""
# if not is_record_public(draft):
# return False
#
# resource_type = draft["metadata"]["resource_type"]["id"]
# research_resource_types = current_app.config.get(
# "CDS_CERN_SCIENTIFIC_RESOURCE_TYPES", set()
# )
# if resource_type not in research_resource_types:
# return False
#
# # Skip if the record is in the Scientific Community or the Related Research Community already
# # IMPORTANT:
# # 1. For thesis, we have the component CDSResourcePublication to validate the community selection
# # 2. For other resource types, it is highly unlikely that the record is NOT eligible for inclusion
# # in the CERN Research Community, since these works typically belong to CERN
# # On the off chance if there is a rare case, it will be dealt via support on case by case basis
# communities_to_skip = [
# current_app.config["CDS_CERN_SCIENTIFIC_COMMUNITY_ID"],
# current_app.config["CDS_CERN_RELATED_RESEARCH_COMMUNITY_ID"],
# ]
# for community_id in communities_to_skip:
# if not community_id:
# current_app.logger.error(
# f"Scientific Community IDs are not configured; "
# "skipping auto community inclusion for record %s.",
# record.pid.pid_value,
# )
# return False
# if community_id in record.parent.communities.ids:
# return False
#
# return True
#
# def publish(self, identity, draft=None, record=None, **kwargs):
# """Schedule community inclusion request after the record is published."""
# if not self._is_eligible(draft, record):
# return
#
# self.uow.register(
# TaskOp(
# submit_community_inclusion_request,
# record_id=record.pid.pid_value,
# )
# )
Loading
Loading