diff --git a/oarepo_requests/config.py b/oarepo_requests/config.py index 29b43dfd..9d94611a 100644 --- a/oarepo_requests/config.py +++ b/oarepo_requests/config.py @@ -26,6 +26,7 @@ PublishDraftRequestType, ) from invenio_requests.customizations import CommentEventType, LogEventType +import invenio_requests.config from invenio_requests.services.permissions import ( PermissionPolicy as InvenioRequestsPermissionPolicy, ) @@ -39,7 +40,7 @@ REQUESTS_REGISTERED_EVENT_TYPES = [ TopicUpdateEventType(), -] +] + invenio_requests.config.REQUESTS_REGISTERED_EVENT_TYPES REQUESTS_ALLOWED_RECEIVERS = ["user", "group", "auto_approve"] diff --git a/oarepo_requests/ext.py b/oarepo_requests/ext.py index 4f2a402f..7ec4b249 100644 --- a/oarepo_requests/ext.py +++ b/oarepo_requests/ext.py @@ -106,9 +106,10 @@ def init_config(self, app): config.DEFAULT_WORKFLOW_EVENT_SUBMITTERS ) - app.config.setdefault("REQUESTS_REGISTERED_EVENT_TYPES", []).extend( - config.REQUESTS_REGISTERED_EVENT_TYPES - ) + app_registered_event_types = app.config.setdefault("REQUESTS_REGISTERED_EVENT_TYPES", []) + for event_type in config.REQUESTS_REGISTERED_EVENT_TYPES: + if event_type not in app_registered_event_types: + app_registered_event_types.append(event_type) def api_finalize_app(app): diff --git a/oarepo_requests/types/publish_draft.py b/oarepo_requests/types/publish_draft.py index 5ef485ef..f6d7e471 100644 --- a/oarepo_requests/types/publish_draft.py +++ b/oarepo_requests/types/publish_draft.py @@ -5,7 +5,6 @@ from invenio_records_resources.services.uow import RecordCommitOp from invenio_requests.proxies import current_requests_service from invenio_requests.records.api import Request -from marshmallow import ValidationError from oarepo_runtime.datastreams.utils import get_record_service_for_record from oarepo_runtime.i18n import lazy_gettext as _ @@ -68,14 +67,7 @@ def can_possibly_create(self, identity, topic, *args, **kwargs): if not topic.is_draft: return False super_ = super().can_possibly_create(identity, topic, *args, **kwargs) - if not super_: - return False - topic_service = get_record_service_for_record(topic) - try: - topic_service.validate_draft(system_identity, topic["id"]) - return True - except ValidationError: - return False + return super_ def topic_change(self, request: Request, new_topic: Dict, uow): setattr(request, "topic", new_topic) diff --git a/setup.cfg b/setup.cfg index 6b13978b..adc96590 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = oarepo-requests -version = 2.1.2 +version = 2.1.3 description = authors = Ronald Krist readme = README.md