Skip to content

Commit

Permalink
Merge pull request #60 from oarepo/better-event-type-registration
Browse files Browse the repository at this point in the history
Fixed event type registration
  • Loading branch information
mesemus authored Sep 22, 2024
2 parents c639c84 + 11f97c8 commit d217af7
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 14 deletions.
3 changes: 2 additions & 1 deletion oarepo_requests/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand All @@ -39,7 +40,7 @@

REQUESTS_REGISTERED_EVENT_TYPES = [
TopicUpdateEventType(),
]
] + invenio_requests.config.REQUESTS_REGISTERED_EVENT_TYPES

REQUESTS_ALLOWED_RECEIVERS = ["user", "group", "auto_approve"]

Expand Down
7 changes: 4 additions & 3 deletions oarepo_requests/ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
10 changes: 1 addition & 9 deletions oarepo_requests/types/publish_draft.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 _

Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = oarepo-requests
version = 2.1.2
version = 2.1.3
description =
authors = Ronald Krist <[email protected]>
readme = README.md
Expand Down

0 comments on commit d217af7

Please sign in to comment.