From b8b65ca61532d4f4fdb338a5ab86cb49223bbbc6 Mon Sep 17 00:00:00 2001 From: Ronald Krist Date: Fri, 18 Oct 2024 10:40:06 +0200 Subject: [PATCH 1/3] default value for editable field in oarepo request type changed --- oarepo_requests/types/generic.py | 5 +++++ .../test_allowed_request_types_link_and_service.py | 8 ++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/oarepo_requests/types/generic.py b/oarepo_requests/types/generic.py index 3b6f39cb..d0a912ba 100644 --- a/oarepo_requests/types/generic.py +++ b/oarepo_requests/types/generic.py @@ -30,6 +30,11 @@ def available_statuses(cls): def has_form(cls): return hasattr(cls, "form") + @classmethod + @property + def editable(cls): + return hasattr(cls, "form") + def can_create(self, identity, data, receiver, topic, creator, *args, **kwargs): current_requests_service.require_permission( identity, "create", record=topic, request_type=self, **kwargs diff --git a/tests/test_requests/test_allowed_request_types_link_and_service.py b/tests/test_requests/test_allowed_request_types_link_and_service.py index 2d9b6a14..105017f4 100644 --- a/tests/test_requests/test_allowed_request_types_link_and_service.py +++ b/tests/test_requests/test_allowed_request_types_link_and_service.py @@ -234,7 +234,7 @@ def test_ui_serialization( { "dangerous": True, "description": "Request deletion of draft", - "editable": True, + "editable": False, "has_form": False, "links": { "actions": { @@ -279,7 +279,7 @@ def test_ui_serialization( "description": "Request deletion of published record", "name": "Delete record", "dangerous": True, - "editable": True, + "editable": False, "has_form": False, "stateful_description": "Request permission to delete the record.", "stateful_name": "Request record deletion", @@ -294,7 +294,7 @@ def test_ui_serialization( "description": "Request re-opening of published record", "name": "Edit record", "dangerous": False, - "editable": True, + "editable": False, "has_form": False, "stateful_description": "Click to start editing the metadata of the record.", "stateful_name": "Edit record", @@ -309,7 +309,7 @@ def test_ui_serialization( "description": "Request requesting creation of new version of a published record.", "name": "New Version", "dangerous": False, - "editable": True, + "editable": False, "has_form": False, "stateful_description": "Click to start creating a new version of the " "record.", From 3702bb1dcb73e21c8d768fefce98f7ac76c8ab32 Mon Sep 17 00:00:00 2001 From: Ronald Krist Date: Fri, 18 Oct 2024 14:14:31 +0200 Subject: [PATCH 2/3] version bump --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index 5ae9bf95..c24c5be7 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = oarepo-requests -version = 2.2.1 +version = 2.2.2 description = authors = Ronald Krist readme = README.md From 2aa70175841362a93df4760c02dcb88dcfe4ccff Mon Sep 17 00:00:00 2001 From: Ronald Krist Date: Fri, 18 Oct 2024 14:23:44 +0200 Subject: [PATCH 3/3] editable uses cls.has_form instead of redefining it --- oarepo_requests/types/generic.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/oarepo_requests/types/generic.py b/oarepo_requests/types/generic.py index aa8f74ea..ff0d503b 100644 --- a/oarepo_requests/types/generic.py +++ b/oarepo_requests/types/generic.py @@ -18,7 +18,6 @@ class OARepoRequestType(RequestType): description = None dangerous = False - editable = True @classmethod @property @@ -33,7 +32,7 @@ def has_form(cls): @classmethod @property def editable(cls): - return hasattr(cls, "form") + return cls.has_form def can_create(self, identity, data, receiver, topic, creator, *args, **kwargs): current_requests_service.require_permission(