Skip to content

Commit

Permalink
Merge pull request #189 from M3nin0/marketplace
Browse files Browse the repository at this point in the history
marketplace: disable doi minting
  • Loading branch information
M3nin0 authored Feb 16, 2024
2 parents ecffe5d + 5300e90 commit 069a698
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 5 deletions.
12 changes: 12 additions & 0 deletions geo_rdm_records/modules/marketplace/resources/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,22 @@

"""GEO Marketplace Resource."""

from flask import abort
from invenio_rdm_records.resources.resources import (
RDMRecordResource as BaseRecordResource,
)


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)
10 changes: 6 additions & 4 deletions geo_rdm_records/modules/marketplace/services/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,16 @@

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
from geo_rdm_records.modules.marketplace.records.api import (
GEOMarketplaceItem,
GEOMarketplaceItemDraft,
)
from geo_rdm_records.modules.marketplace.services.permissions import (
MarketplacePermissionPolicy,
)
from geo_rdm_records.modules.packages.services.links import RecordLink


Expand All @@ -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,
)

Expand Down Expand Up @@ -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,
)

Expand Down Expand Up @@ -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,
)

Expand Down
26 changes: 26 additions & 0 deletions geo_rdm_records/modules/marketplace/services/permissions.py
Original file line number Diff line number Diff line change
@@ -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()]
13 changes: 13 additions & 0 deletions geo_rdm_records/modules/marketplace/services/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
#
Expand Down
12 changes: 11 additions & 1 deletion geo_rdm_records/modules/search/services/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand All @@ -64,6 +73,7 @@ class SearchRecordServiceConfig(BaseGEOServiceConfig):
# Links
links_registry_type = LinksRegistryType

# ToDo: Review links
links_item = {
"self": ConditionalLink(
cond=is_record,
Expand Down

0 comments on commit 069a698

Please sign in to comment.