diff --git a/geo_rdm_records/modules/marketplace/resources/resource.py b/geo_rdm_records/modules/marketplace/resources/resource.py index 6dcaee7..b456747 100644 --- a/geo_rdm_records/modules/marketplace/resources/resource.py +++ b/geo_rdm_records/modules/marketplace/resources/resource.py @@ -7,6 +7,7 @@ """GEO Marketplace Resource.""" +from flask import abort from invenio_rdm_records.resources.resources import ( RDMRecordResource as BaseRecordResource, ) @@ -14,3 +15,14 @@ class GEOMarketplaceItemResource(BaseRecordResource): """GEO Marketplace Item resource.""" + + # + # PIDs + # + def pids_reserve(self): + """Reserve a PID.""" + abort(403) + + def pids_discard(self): + """Discard a previously reserved PID.""" + abort(403) diff --git a/geo_rdm_records/modules/marketplace/services/config.py b/geo_rdm_records/modules/marketplace/services/config.py index 90da71d..03772c6 100644 --- a/geo_rdm_records/modules/marketplace/services/config.py +++ b/geo_rdm_records/modules/marketplace/services/config.py @@ -32,7 +32,6 @@ from geo_rdm_records.base.services.config import BaseGEOServiceConfig from geo_rdm_records.base.services.links import LinksRegistryType -from geo_rdm_records.base.services.permissions import BaseGEOPermissionPolicy from geo_rdm_records.base.services.results import MutableRecordList, ResultRegistryType from geo_rdm_records.base.services.schemas import ParentSchema from geo_rdm_records.base.services.schemas.records import BaseGEORecordSchema @@ -40,6 +39,9 @@ GEOMarketplaceItem, GEOMarketplaceItemDraft, ) +from geo_rdm_records.modules.marketplace.services.permissions import ( + MarketplacePermissionPolicy, +) from geo_rdm_records.modules.packages.services.links import RecordLink @@ -64,7 +66,7 @@ class GEOMarketplaceServiceConfig(BaseGEOServiceConfig): # Permission policy permission_policy_cls = FromConfig( "GEO_MARKETPLACE_ITEMS_PERMISSION_POLICY", - default=BaseGEOPermissionPolicy, # ToDo: Review permissions for Marketplace + default=MarketplacePermissionPolicy, # ToDo: Review permissions for Marketplace import_string=True, ) @@ -158,7 +160,7 @@ class GEOMarketplaceItemFileServiceConfig(rdm_config.RDMFileRecordServiceConfig) # Permission policy permission_policy_cls = FromConfig( "GEO_MARKETPLACE_ITEMS_PERMISSION_POLICY", - default=BaseGEOPermissionPolicy, # ToDo: Review permissions for Marketplace + default=MarketplacePermissionPolicy, # ToDo: Review permissions for Marketplace import_string=True, ) @@ -196,7 +198,7 @@ class GEOMarketplaceItemDraftFileServiceConfig(rdm_config.RDMFileDraftServiceCon permission_action_prefix = "draft_" permission_policy_cls = FromConfig( "GEO_MARKETPLACE_ITEMS_PERMISSION_POLICY", - default=BaseGEOPermissionPolicy, # ToDo: Review permissions for Marketplace + default=MarketplacePermissionPolicy, # ToDo: Review permissions for Marketplace import_string=True, ) diff --git a/geo_rdm_records/modules/marketplace/services/permissions.py b/geo_rdm_records/modules/marketplace/services/permissions.py new file mode 100644 index 0000000..0afdc62 --- /dev/null +++ b/geo_rdm_records/modules/marketplace/services/permissions.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- +# +# Copyright (C) 2022-2024 GEO Secretariat. +# +# geo-rdm-records is free software; you can redistribute it and/or modify it +# under the terms of the MIT License; see LICENSE file for more details. + +"""GEO Marketplace service permissions.""" + +from invenio_records_permissions.generators import Disable + +from geo_rdm_records.base.services.permissions import BaseGEOPermissionPolicy + + +class MarketplacePermissionPolicy(BaseGEOPermissionPolicy): + """Access control configuration for marketplace items.""" + + # + # Disabled actions (these should not be used or changed) + # + # Marketplace Items can not have DOIs. + can_pid_create = [Disable()] + can_pid_register = [Disable()] + can_pid_update = [Disable()] + can_pid_discard = [Disable()] + can_pid_delete = [Disable()] diff --git a/geo_rdm_records/modules/marketplace/services/service.py b/geo_rdm_records/modules/marketplace/services/service.py index 8603ac2..dd215bc 100644 --- a/geo_rdm_records/modules/marketplace/services/service.py +++ b/geo_rdm_records/modules/marketplace/services/service.py @@ -15,6 +15,19 @@ class GEOMarketplaceItemService(BaseRecordService): """GEO Marketplace Item Service.""" + def __init__( + self, + config, + files_service=None, + draft_files_service=None, + secret_links_service=None, + review_service=None, + ): + """Initializer.""" + super().__init__(config, files_service, draft_files_service) + self._secret_links = secret_links_service + self._review = review_service + # # Properties # diff --git a/geo_rdm_records/modules/search/services/config.py b/geo_rdm_records/modules/search/services/config.py index 3f4492e..8821714 100644 --- a/geo_rdm_records/modules/search/services/config.py +++ b/geo_rdm_records/modules/search/services/config.py @@ -23,6 +23,10 @@ from geo_rdm_records.base.services.permissions import BaseGEOPermissionPolicy from geo_rdm_records.base.services.results import MutableRecordList, ResultRegistryType from geo_rdm_records.base.services.schemas import ParentSchema +from geo_rdm_records.modules.marketplace.records.api import ( + GEOMarketplaceItem, + GEOMarketplaceItemDraft, +) from geo_rdm_records.modules.packages.records.api import ( GEOPackageDraft, GEOPackageRecord, @@ -42,9 +46,14 @@ class SearchRecordServiceConfig(BaseGEOServiceConfig): indices = [ GEORecord.index.search_alias, GEOPackageRecord.index.search_alias, + GEOMarketplaceItem.index.search_alias, ] - indices_draft = [GEODraft.index.search_alias, GEOPackageDraft.index.search_alias] + indices_draft = [ + GEODraft.index.search_alias, + GEOPackageDraft.index.search_alias, + GEOMarketplaceItemDraft.index.search_alias, + ] # Schemas schema = GEORecordSchema @@ -64,6 +73,7 @@ class SearchRecordServiceConfig(BaseGEOServiceConfig): # Links links_registry_type = LinksRegistryType + # ToDo: Review links links_item = { "self": ConditionalLink( cond=is_record,