From af7eb4f9b14917d0e75a5e8e24d1e2aa018f82df Mon Sep 17 00:00:00 2001 From: Mirek Simek Date: Thu, 17 Oct 2024 09:06:31 +0200 Subject: [PATCH 1/2] Fixed stateful api inconsistencies --- oarepo_requests/services/ui_schema.py | 1 - oarepo_requests/types/delete_draft.py | 4 ++-- oarepo_requests/types/delete_published_record.py | 4 ++-- oarepo_requests/types/edit_record.py | 4 ++-- oarepo_requests/types/generic.py | 4 ++-- oarepo_requests/types/new_version.py | 4 ++-- oarepo_requests/types/publish_draft.py | 4 ++-- setup.cfg | 2 +- 8 files changed, 13 insertions(+), 14 deletions(-) diff --git a/oarepo_requests/services/ui_schema.py b/oarepo_requests/services/ui_schema.py index 4c757e80..925e4d26 100644 --- a/oarepo_requests/services/ui_schema.py +++ b/oarepo_requests/services/ui_schema.py @@ -1,4 +1,3 @@ -from types import SimpleNamespace import marshmallow as ma from invenio_pidstore.errors import PIDDeletedError diff --git a/oarepo_requests/types/delete_draft.py b/oarepo_requests/types/delete_draft.py index b8166a5f..0f1c6f6b 100644 --- a/oarepo_requests/types/delete_draft.py +++ b/oarepo_requests/types/delete_draft.py @@ -26,7 +26,7 @@ def available_actions(cls): allowed_topic_ref_types = ModelRefTypes(published=False, draft=True) @override - def stateful_name(self, identity, *, topic=None, request=None): + def stateful_name(self, identity, *, topic, request=None, **kwargs): if is_auto_approved(self, identity=identity, topic=topic): return self.name if not request: @@ -38,7 +38,7 @@ def stateful_name(self, identity, *, topic=None, request=None): return _("Request draft deletion") @override - def stateful_description(self, identity, *, topic=None, request=None): + def stateful_description(self, identity, *, topic, request=None, **kwargs): if is_auto_approved(self, identity=identity, topic=topic): return _("Click to permanently delete the draft.") diff --git a/oarepo_requests/types/delete_published_record.py b/oarepo_requests/types/delete_published_record.py index c5ee6a60..69670b2a 100644 --- a/oarepo_requests/types/delete_published_record.py +++ b/oarepo_requests/types/delete_published_record.py @@ -29,7 +29,7 @@ def available_actions(cls): allowed_topic_ref_types = ModelRefTypes(published=True, draft=False) @override - def stateful_name(self, identity, *, topic=None, request=None): + def stateful_name(self, identity, *, topic, request=None, **kwargs): if is_auto_approved(self, identity=identity, topic=topic): return self.name if not request: @@ -41,7 +41,7 @@ def stateful_name(self, identity, *, topic=None, request=None): return _("Request record deletion") @override - def stateful_description(self, identity, *, topic=None, request=None): + def stateful_description(self, identity, *, topic, request=None, **kwargs): if is_auto_approved(self, identity=identity, topic=topic): return _("Click to permanently delete the record.") diff --git a/oarepo_requests/types/edit_record.py b/oarepo_requests/types/edit_record.py index 9bce216d..9ecbf3f9 100644 --- a/oarepo_requests/types/edit_record.py +++ b/oarepo_requests/types/edit_record.py @@ -58,7 +58,7 @@ def topic_change(self, request: Request, new_topic: Dict, uow): uow.register(RecordCommitOp(request, indexer=current_requests_service.indexer)) @override - def stateful_name(self, identity, *, topic=None, request=None): + def stateful_name(self, identity, *, topic, request=None, **kwargs): if is_auto_approved(self, identity=identity, topic=topic): return self.name if not request: @@ -70,7 +70,7 @@ def stateful_name(self, identity, *, topic=None, request=None): return _("Request edit access") @override - def stateful_description(self, identity, *, topic=None, request=None): + def stateful_description(self, identity, *, topic, request=None, **kwargs): if is_auto_approved(self, identity=identity, topic=topic): return _("Click to start editing the metadata of the record.") diff --git a/oarepo_requests/types/generic.py b/oarepo_requests/types/generic.py index 3b6f39cb..85e1bb9f 100644 --- a/oarepo_requests/types/generic.py +++ b/oarepo_requests/types/generic.py @@ -65,7 +65,7 @@ def available_actions(cls): "decline": OARepoDeclineAction, } - def stateful_name(self, identity, request): + def stateful_name(self, *, identity, topic, request=None, **kwargs): """ Returns the name of the request that reflects its current state. @@ -74,7 +74,7 @@ def stateful_name(self, identity, request): """ return self.name - def stateful_description(self, identity, request): + def stateful_description(self, *, identity, topic, request=None, **kwargs): """ Returns the description of the request that reflects its current state. diff --git a/oarepo_requests/types/new_version.py b/oarepo_requests/types/new_version.py index 14060656..8e0ebf74 100644 --- a/oarepo_requests/types/new_version.py +++ b/oarepo_requests/types/new_version.py @@ -58,7 +58,7 @@ def topic_change(self, request: Request, new_topic: Dict, uow): uow.register(RecordCommitOp(request, indexer=current_requests_service.indexer)) @override - def stateful_name(self, identity, *, topic=None, request=None): + def stateful_name(self, identity, *, topic, request=None, **kwargs): if is_auto_approved(self, identity=identity, topic=topic): return self.name if not request: @@ -70,7 +70,7 @@ def stateful_name(self, identity, *, topic=None, request=None): return _("Request new version access") @override - def stateful_description(self, identity, *, topic=None, request=None): + def stateful_description(self, identity, *, topic, request=None, **kwargs): if is_auto_approved(self, identity=identity, topic=topic): return _("Click to start creating a new version of the record.") diff --git a/oarepo_requests/types/publish_draft.py b/oarepo_requests/types/publish_draft.py index 3d97e3ed..9d067a1c 100644 --- a/oarepo_requests/types/publish_draft.py +++ b/oarepo_requests/types/publish_draft.py @@ -76,7 +76,7 @@ def topic_change(self, request: Request, new_topic: Dict, uow): uow.register(RecordCommitOp(request, indexer=current_requests_service.indexer)) @override - def stateful_name(self, identity, *, topic=None, request=None): + def stateful_name(self, identity, *, topic, request=None, **kwargs): if is_auto_approved(self, identity=identity, topic=topic): return _("Publish draft") if not request: @@ -88,7 +88,7 @@ def stateful_name(self, identity, *, topic=None, request=None): return _("Submit for review") @override - def stateful_description(self, identity, *, topic=None, request=None): + def stateful_description(self, identity, *, topic, request=None, **kwargs): if is_auto_approved(self, identity=identity, topic=topic): return _( "Click to immediately publish the draft. " diff --git a/setup.cfg b/setup.cfg index 9a61e447..5ae9bf95 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = oarepo-requests -version = 2.2.0 +version = 2.2.1 description = authors = Ronald Krist readme = README.md From d2cf4cdc6ac0c597aaeb03eaf179d0753ff596d0 Mon Sep 17 00:00:00 2001 From: Mirek Simek Date: Thu, 17 Oct 2024 09:17:45 +0200 Subject: [PATCH 2/2] Returned missing import --- oarepo_requests/services/ui_schema.py | 1 + 1 file changed, 1 insertion(+) diff --git a/oarepo_requests/services/ui_schema.py b/oarepo_requests/services/ui_schema.py index 925e4d26..4c757e80 100644 --- a/oarepo_requests/services/ui_schema.py +++ b/oarepo_requests/services/ui_schema.py @@ -1,3 +1,4 @@ +from types import SimpleNamespace import marshmallow as ma from invenio_pidstore.errors import PIDDeletedError