Skip to content

Commit

Permalink
marketplace: adding community review support for marketplace items
Browse files Browse the repository at this point in the history
  • Loading branch information
M3nin0 committed Feb 21, 2024
1 parent 446b9b3 commit dd3db30
Show file tree
Hide file tree
Showing 15 changed files with 141 additions and 20 deletions.
14 changes: 0 additions & 14 deletions geo_rdm_records/base/requests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,9 @@

"""GEO RDM Records Requests."""

from .community_submission import (
AcceptAction,
CancelAction,
DeclineAction,
ExpireAction,
ServiceHandler,
SubmitAction,
)
from .resolver import BaseRecordProxy, BaseRecordResolver

__all__ = (
"BaseRecordProxy",
"BaseRecordResolver",
"ServiceHandler",
"SubmitAction",
"AcceptAction",
"DeclineAction",
"CancelAction",
"ExpireAction",
)
6 changes: 6 additions & 0 deletions geo_rdm_records/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from invenio_rdm_records.services import facets as rdm_facets

from geo_rdm_records.base.services import facets as geo_facets
from geo_rdm_records.modules.requests.community.config import CommunitySubmissionConfig
from geo_rdm_records.modules.security.permissions import views_permissions_factory

# UI Configurations
Expand Down Expand Up @@ -164,6 +165,11 @@
"sort": ["bestmatch", "updated-desc", "updated-asc", "newest", "oldest", "version"],
}

#
# Review
#
RDM_COMMUNITY_SUBMISSION_OVERRIDE_CONFIG = CommunitySubmissionConfig

#
# Requests
#
Expand Down
12 changes: 9 additions & 3 deletions geo_rdm_records/ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@
from invenio_records_resources.resources.files import FileResource
from invenio_records_resources.services import FileService

from geo_rdm_records.modules.requests.notification.services.config import (
RequestNotificationServiceConfig,
)
from geo_rdm_records.modules.requests.notification.services.service import (
RequestNotificationService,
)

from . import config
from .modules.marketplace.resources.config import (
GEOMarketplaceItemDraftResourceConfig,
Expand Down Expand Up @@ -46,8 +53,6 @@
from .modules.packages.services.request.service import PackageRequestsService
from .modules.packages.services.secret_links import SecretLinkService
from .modules.packages.services.service import GEOPackageRecordService
from .modules.requests.services.config import RequestNotificationServiceConfig
from .modules.requests.services.service import RequestNotificationService
from .modules.search.resources.config import SearchRecordResourceConfig
from .modules.search.resources.resource import SearchRecordResource
from .modules.search.services.config import SearchRecordServiceConfig
Expand Down Expand Up @@ -104,7 +109,7 @@ def init_services(self, app):

# Services
self.service = GEOPackageRecordService(
service_configs.record,
config=service_configs.record,
files_service=FileService(service_configs.file),
draft_files_service=FileService(service_configs.file_draft),
secret_links_service=SecretLinkService(service_configs.record),
Expand All @@ -128,6 +133,7 @@ def init_services(self, app):
config=service_configs.marketplace_item,
files_service=FileService(service_configs.marketplace_file),
draft_files_service=FileService(service_configs.marketplace_file_draft),
review_service=ReviewService(service_configs.marketplace_item),
)

def init_resource(self, app):
Expand Down
8 changes: 8 additions & 0 deletions geo_rdm_records/modules/marketplace/requests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# -*- 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 requests resolver."""
48 changes: 48 additions & 0 deletions geo_rdm_records/modules/marketplace/requests/resolver.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# -*- coding: utf-8 -*-
#
# Copyright (C) 2022 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 RDM Records Resources requests resolver."""

from geo_rdm_records.base.requests import BaseRecordProxy, BaseRecordResolver

from ..records.api import GEOMarketplaceItem, GEOMarketplaceItemDraft


class RecordProxy(BaseRecordProxy):
"""Proxy for draft or record classes."""

record_cls = GEOMarketplaceItem

draft_cls = GEOMarketplaceItemDraft


class MarketplaceItemDraftResolver(BaseRecordResolver):
"""Marketplace Item draft entity resolver."""

type_id = "marketplace-items"

record_cls = GEOMarketplaceItemDraft

proxy_cls = RecordProxy

service_id = "marketplace_items"

type_key = "marketplace_item"


class MarketplaceItemResolver(BaseRecordResolver):
"""Marketplace Item entity resolver."""

type_id = "marketplace-item-record"

record_cls = GEOMarketplaceItem

proxy_cls = RecordProxy

service_id = "marketplace_items"

type_key = "marketplace_item_record"
8 changes: 8 additions & 0 deletions geo_rdm_records/modules/requests/community/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# -*- coding: utf-8 -*-
#
# Copyright (C) 2022 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.

"""Community requests configurations."""
37 changes: 37 additions & 0 deletions geo_rdm_records/modules/requests/community/config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# -*- coding: utf-8 -*-
#
# Copyright (C) 2022 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.

"""Community-related requests."""

from invenio_requests.customizations import actions

from geo_rdm_records.modules.requests.community.submission import (
AcceptAction,
CancelAction,
DeclineAction,
ExpireAction,
SubmitAction,
)

#
# Extra configurations for the `CommunitySubmission` class
# > This configuration is possible as in the GEO Knowledge Hub, we use a
# > custom version of the `CommunitySubmission` class, which has support for
# > `overridable configurations.`
#
CommunitySubmissionConfig = {
"allowed_topic_ref_types": ["record", "package", "marketplace_item"],
"available_actions": {
"create": actions.CreateAction,
"submit": SubmitAction,
"delete": actions.DeleteAction,
"accept": AcceptAction,
"cancel": CancelAction,
"decline": DeclineAction,
"expire": ExpireAction,
},
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,19 @@
from invenio_records_resources.services.uow import RecordCommitOp, RecordIndexOp
from invenio_requests.customizations import actions

from geo_rdm_records.modules.marketplace.records.api import (
GEOMarketplaceItem,
GEOMarketplaceItemDraft,
)
from geo_rdm_records.modules.packages.records.api import (
GEOPackageDraft,
GEOPackageRecord,
)
from geo_rdm_records.modules.rdm import GEODraft, GEORecord
from geo_rdm_records.proxies import current_geo_packages_service
from geo_rdm_records.proxies import (
current_geo_packages_service,
current_marketplace_service,
)


class ServiceHandler:
Expand All @@ -43,6 +50,10 @@ class ServiceHandler:
"classes": (GEOPackageDraft, GEOPackageRecord),
"service": current_geo_packages_service,
},
{
"classes": (GEOMarketplaceItem, GEOMarketplaceItemDraft),
"service": current_marketplace_service,
},
]
"""Definition of the services available to handle actions."""

Expand Down
8 changes: 8 additions & 0 deletions geo_rdm_records/modules/requests/notification/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# -*- coding: utf-8 -*-
#
# Copyright (C) 2022 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.

"""Requests notification."""
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from invenio_records_resources.services.base import Service
from invenio_records_resources.services.uow import TaskOp, unit_of_work

from geo_rdm_records.modules.requests.tasks import notify_request
from geo_rdm_records.modules.requests.notification.tasks import notify_request


class RequestNotificationService(Service):
Expand Down
File renamed without changes.
5 changes: 4 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ install_requires =
requests-cache>=1.1.0,<1.2.0
invenio-i18n>=1.2.0
invenio-oaiserver>=2.0.0,<2.2.0
invenio-rdm-records @ git+https://github.com/geo-knowledge-hub/invenio-rdm-records@b-1.6
invenio-rdm-records @ git+https://github.com/geo-knowledge-hub/invenio-rdm-records@b-1.7

[options.extras_require]
docs =
Expand Down Expand Up @@ -102,13 +102,16 @@ invenio_requests.entity_resolvers =
resources = geo_rdm_records.modules.rdm.requests.resolver:RecordResolver
packages = geo_rdm_records.modules.packages.requests.resolver:PackageDraftResolver
packages_record = geo_rdm_records.modules.packages.requests.resolver:PackageRecordResolver
marketplace_item = geo_rdm_records.modules.marketplace.requests.resolver:MarketplaceItemDraftResolver
marketplace_item_record = geo_rdm_records.modules.marketplace.requests.resolver:MarketplaceItemResolver
invenio_assets.webpack =
geo_rdm_records = geo_rdm_records.webpack:theme
invenio_db.alembic =
geo_rdm_records = geo_rdm_records:alembic
invenio_celery.tasks =
geo_rdm_records_packages = geo_rdm_records.modules.packages.services.tasks
geo_rdm_records_checker = geo_rdm_records.modules.checker.tasks
geo_rdm_records_requests_notification = geo_rdm_records.modules.requests.notification.tasks

[build_sphinx]
source-dir = docs/
Expand Down

0 comments on commit dd3db30

Please sign in to comment.