From 735670198cbca053dea6f952bec8e9a795fe730f Mon Sep 17 00:00:00 2001 From: Ronald Krist Date: Mon, 2 Dec 2024 13:41:06 +0100 Subject: [PATCH 1/4] ui serializer for auto approve entity --- oarepo_requests/config.py | 3 +- oarepo_requests/resolvers/ui.py | 59 ++++ .../translations/cs/LC_MESSAGES/messages.mo | Bin 15375 -> 15375 bytes .../translations/cs/LC_MESSAGES/messages.po | 14 + .../translations/en/LC_MESSAGES/messages.mo | Bin 966 -> 966 bytes .../translations/en/LC_MESSAGES/messages.po | 14 + oarepo_requests/translations/messages.mo | Bin 395 -> 395 bytes oarepo_requests/translations/messages.pot | 251 +++++++++--------- .../test_requests/test_ui_serialialization.py | 29 ++ 9 files changed, 249 insertions(+), 121 deletions(-) diff --git a/oarepo_requests/config.py b/oarepo_requests/config.py index 52a38d1..279cbd2 100644 --- a/oarepo_requests/config.py +++ b/oarepo_requests/config.py @@ -23,7 +23,7 @@ from oarepo_requests.resolvers.ui import ( FallbackEntityReferenceUIResolver, GroupEntityReferenceUIResolver, - UserEntityReferenceUIResolver, + UserEntityReferenceUIResolver, AutoApproveUIEntityResolver, ) from oarepo_requests.types import ( DeletePublishedRecordRequestType, @@ -63,6 +63,7 @@ "user": UserEntityReferenceUIResolver("user"), "fallback": FallbackEntityReferenceUIResolver("fallback"), "group": GroupEntityReferenceUIResolver("group"), + "auto_approve": AutoApproveUIEntityResolver("auto_approve"), } REQUESTS_UI_SERIALIZATION_REFERENCED_FIELDS = ["created_by", "receiver", "topic"] diff --git a/oarepo_requests/resolvers/ui.py b/oarepo_requests/resolvers/ui.py index deae4e9..9b0477d 100644 --- a/oarepo_requests/resolvers/ui.py +++ b/oarepo_requests/resolvers/ui.py @@ -543,3 +543,62 @@ def _get_entity_ui_representation( label=label, links=self._extract_links_from_resolved_reference(entity), ) + +class KeywordUIEntityResolver(OARepoUIResolver): + keyword = None + + @override + def _get_id(self, entity: dict) -> str: + """Get the id of the serialized entity. + + :result: value of the keyword of the entity + """ + return list(entity.values())[0] + + @override + def _search_many( + self, identity: Identity, ids: list[str], *args: Any, **kwargs: Any + ) -> list[dict]: + """Returns list of references of keyword entities. + + :param identity: identity of the user + :param ids: ids to search for + :param args: additional arguments + :param kwargs: additional keyword arguments + :return: list of records found + """ + return [{self.keyword: _id} for _id in ids] + + @override + def _search_one( + self, identity: Identity, _id: str, *args: Any, **kwargs: Any + ) -> dict | None: + """Returns keyword entity reference. + + :param identity: identity of the user + :param _id: the keyword value + :return: API serialization of the data + """ + return {self.keyword: _id} + +class AutoApproveUIEntityResolver(KeywordUIEntityResolver): + keyword = "auto_approve" + + @override + def _get_entity_ui_representation( + self, entity: dict, reference: EntityReference + ) -> UIResolvedReference: + """Create a UI representation of an auto approve entity. + + :entity: resolved entity + :reference: reference to the entity + :return: UI representation of the entity + """ + + return UIResolvedReference( + reference=reference, + type=self.keyword, + label=_("Auto approve"), + links={}, + ) + diff --git a/oarepo_requests/translations/cs/LC_MESSAGES/messages.mo b/oarepo_requests/translations/cs/LC_MESSAGES/messages.mo index 0e7a2eb3fc5e7ce542978bf0db6aac14b92ec1a2..33b1958f41ffb6b388077a74bb1820e82440fc41 100644 GIT binary patch delta 14 VcmeCL=&#riqReQzIaGO<1OP0}1!({P delta 14 VcmeCL=&#riqReQvIaGO<1OP141!@2Q diff --git a/oarepo_requests/translations/cs/LC_MESSAGES/messages.po b/oarepo_requests/translations/cs/LC_MESSAGES/messages.po index f525554..3ccc0b7 100644 --- a/oarepo_requests/translations/cs/LC_MESSAGES/messages.po +++ b/oarepo_requests/translations/cs/LC_MESSAGES/messages.po @@ -726,3 +726,17 @@ msgstr "smazal(a) komentář" msgid "Remaining characters: " msgstr "Zbývající znaky: " + +#: /home/ron/prace/oarepo-requests/oarepo_requests/resolvers/ui.py:594 +msgid "Auto approve" +msgstr "Automaticky schváleno" + +#: /home/ron/prace/oarepo-requests/oarepo_requests/types/publish_draft.py:120 +msgid "" +"Missing uploaded files. To disable files for this record please mark it as " +"metadata-only." +msgstr "Chybí nahrané soubory. Označte záznam jako 'pouze metadata' pokud je nahrávat neplánujete." + +#: /home/ron/prace/oarepo-requests/oarepo_requests/types/publish_draft.py:124 +msgid "Missing uploaded files." +msgstr "Chybí nahrané soubory." diff --git a/oarepo_requests/translations/en/LC_MESSAGES/messages.mo b/oarepo_requests/translations/en/LC_MESSAGES/messages.mo index dc66058d8983482ca1e809f8f8ce093cc2425fda..57f1e7502ea8a17b01247889dfef455769a2cc4f 100644 GIT binary patch delta 12 TcmX@cevEy?e\n" "Language-Team: LANGUAGE \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" -"Generated-By: Babel 2.16.0\n" +"Generated-By: Babel 2.15.0\n" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/invenio_patches.py:163 +#: /home/ron/prace/oarepo-requests/oarepo_requests/invenio_patches.py:163 msgid "Submitted" msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/invenio_patches.py:164 +#: /home/ron/prace/oarepo-requests/oarepo_requests/invenio_patches.py:164 msgid "Expired" msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/invenio_patches.py:165 +#: /home/ron/prace/oarepo-requests/oarepo_requests/invenio_patches.py:165 msgid "Accepted" msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/invenio_patches.py:166 +#: /home/ron/prace/oarepo-requests/oarepo_requests/invenio_patches.py:166 msgid "Declined" msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/invenio_patches.py:167 +#: /home/ron/prace/oarepo-requests/oarepo_requests/invenio_patches.py:167 msgid "Cancelled" msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/invenio_patches.py:169 +#: /home/ron/prace/oarepo-requests/oarepo_requests/invenio_patches.py:169 msgid "Request status" msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/invenio_patches.py:175 +#: /home/ron/prace/oarepo-requests/oarepo_requests/invenio_patches.py:175 msgid "Type" msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/actions/delete_published_record.py:30 +#: /home/ron/prace/oarepo-requests/oarepo_requests/actions/delete_published_record.py:30 msgid "Permanently delete" msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/actions/delete_published_record.py:52 +#: /home/ron/prace/oarepo-requests/oarepo_requests/actions/delete_published_record.py:52 msgid "Keep the record" msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/actions/generic.py:138 -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/translations/_only_for_translations.py:28 +#: /home/ron/prace/oarepo-requests/oarepo_requests/actions/generic.py:138 +#: /home/ron/prace/oarepo-requests/oarepo_requests/translations/_only_for_translations.py:28 msgid "Submit" msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/actions/generic.py:144 -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/translations/_only_for_translations.py:24 +#: /home/ron/prace/oarepo-requests/oarepo_requests/actions/generic.py:144 +#: /home/ron/prace/oarepo-requests/oarepo_requests/translations/_only_for_translations.py:24 msgid "Decline" msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/actions/generic.py:150 -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/translations/_only_for_translations.py:22 +#: /home/ron/prace/oarepo-requests/oarepo_requests/actions/generic.py:150 +#: /home/ron/prace/oarepo-requests/oarepo_requests/translations/_only_for_translations.py:22 msgid "Accept" msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/actions/publish_draft.py:59 +#: /home/ron/prace/oarepo-requests/oarepo_requests/actions/publish_draft.py:59 msgid "Publish" msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/actions/publish_draft.py:92 +#: /home/ron/prace/oarepo-requests/oarepo_requests/actions/publish_draft.py:93 msgid "Return for correction" msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/resolvers/ui.py:333 +#: /home/ron/prace/oarepo-requests/oarepo_requests/resolvers/ui.py:333 msgid "System user" msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/services/ui_schema.py:159 +#: /home/ron/prace/oarepo-requests/oarepo_requests/resolvers/ui.py:594 +msgid "Auto approve" +msgstr "" + +#: /home/ron/prace/oarepo-requests/oarepo_requests/services/ui_schema.py:159 msgid "status" msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/translations/_only_for_translations.py:10 +#: /home/ron/prace/oarepo-requests/oarepo_requests/translations/_only_for_translations.py:10 msgid "Create Request" msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/translations/_only_for_translations.py:11 +#: /home/ron/prace/oarepo-requests/oarepo_requests/translations/_only_for_translations.py:11 msgid "Open dialog for request" msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/translations/_only_for_translations.py:12 +#: /home/ron/prace/oarepo-requests/oarepo_requests/translations/_only_for_translations.py:12 msgid "My Requests" msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/translations/_only_for_translations.py:13 +#: /home/ron/prace/oarepo-requests/oarepo_requests/translations/_only_for_translations.py:13 msgid "Requests to Approve" msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/translations/_only_for_translations.py:14 +#: /home/ron/prace/oarepo-requests/oarepo_requests/translations/_only_for_translations.py:14 msgid "Are you sure?" msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/translations/_only_for_translations.py:15 +#: /home/ron/prace/oarepo-requests/oarepo_requests/translations/_only_for_translations.py:15 msgid "Cancel" msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/translations/_only_for_translations.py:16 +#: /home/ron/prace/oarepo-requests/oarepo_requests/translations/_only_for_translations.py:16 msgid "OK" msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/translations/_only_for_translations.py:17 +#: /home/ron/prace/oarepo-requests/oarepo_requests/translations/_only_for_translations.py:17 msgid "Create request" msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/translations/_only_for_translations.py:18 +#: /home/ron/prace/oarepo-requests/oarepo_requests/translations/_only_for_translations.py:18 msgid "Submit request" msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/translations/_only_for_translations.py:19 +#: /home/ron/prace/oarepo-requests/oarepo_requests/translations/_only_for_translations.py:19 msgid "Delete request" msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/translations/_only_for_translations.py:20 +#: /home/ron/prace/oarepo-requests/oarepo_requests/translations/_only_for_translations.py:20 msgid "Delete" msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/translations/_only_for_translations.py:21 +#: /home/ron/prace/oarepo-requests/oarepo_requests/translations/_only_for_translations.py:21 msgid "Accept request" msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/translations/_only_for_translations.py:23 +#: /home/ron/prace/oarepo-requests/oarepo_requests/translations/_only_for_translations.py:23 msgid "Decline request" msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/translations/_only_for_translations.py:25 +#: /home/ron/prace/oarepo-requests/oarepo_requests/translations/_only_for_translations.py:25 msgid "Create and submit request" msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/translations/_only_for_translations.py:26 +#: /home/ron/prace/oarepo-requests/oarepo_requests/translations/_only_for_translations.py:26 msgid "Create and submit" msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/translations/_only_for_translations.py:27 +#: /home/ron/prace/oarepo-requests/oarepo_requests/translations/_only_for_translations.py:27 msgid "Error sending request" msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/translations/_only_for_translations.py:29 +#: /home/ron/prace/oarepo-requests/oarepo_requests/translations/_only_for_translations.py:29 msgid "Save drafted request" msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/translations/_only_for_translations.py:30 +#: /home/ron/prace/oarepo-requests/oarepo_requests/translations/_only_for_translations.py:30 msgid "Save" msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/translations/_only_for_translations.py:31 +#: /home/ron/prace/oarepo-requests/oarepo_requests/translations/_only_for_translations.py:31 msgid "Create" msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/translations/_only_for_translations.py:32 +#: /home/ron/prace/oarepo-requests/oarepo_requests/translations/_only_for_translations.py:32 msgid "Creator" msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/translations/_only_for_translations.py:33 +#: /home/ron/prace/oarepo-requests/oarepo_requests/translations/_only_for_translations.py:33 msgid "Receiver" msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/translations/_only_for_translations.py:34 +#: /home/ron/prace/oarepo-requests/oarepo_requests/translations/_only_for_translations.py:34 msgid "Request type" msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/translations/_only_for_translations.py:35 +#: /home/ron/prace/oarepo-requests/oarepo_requests/translations/_only_for_translations.py:35 msgid "Created" msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/translations/_only_for_translations.py:36 +#: /home/ron/prace/oarepo-requests/oarepo_requests/translations/_only_for_translations.py:36 msgid "Timeline" msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/translations/_only_for_translations.py:37 +#: /home/ron/prace/oarepo-requests/oarepo_requests/translations/_only_for_translations.py:37 msgid "Submit event" msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/translations/_only_for_translations.py:38 +#: /home/ron/prace/oarepo-requests/oarepo_requests/translations/_only_for_translations.py:38 msgid "No requests to show" msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/translations/_only_for_translations.py:39 +#: /home/ron/prace/oarepo-requests/oarepo_requests/translations/_only_for_translations.py:39 msgid "api.requests" msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/translations/_only_for_translations.py:40 +#: /home/ron/prace/oarepo-requests/oarepo_requests/translations/_only_for_translations.py:40 msgid "api.applicable-requests" msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/types/delete_draft.py:34 +#: /home/ron/prace/oarepo-requests/oarepo_requests/types/delete_draft.py:34 msgid "Delete draft" msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/types/delete_draft.py:46 +#: /home/ron/prace/oarepo-requests/oarepo_requests/types/delete_draft.py:46 msgid "Request deletion of draft" msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/types/delete_draft.py:63 -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/types/delete_draft.py:68 +#: /home/ron/prace/oarepo-requests/oarepo_requests/types/delete_draft.py:63 +#: /home/ron/prace/oarepo-requests/oarepo_requests/types/delete_draft.py:68 msgid "Request draft deletion" msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/types/delete_draft.py:66 +#: /home/ron/prace/oarepo-requests/oarepo_requests/types/delete_draft.py:66 msgid "Draft deletion requested" msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/types/delete_draft.py:81 +#: /home/ron/prace/oarepo-requests/oarepo_requests/types/delete_draft.py:81 msgid "Click to permanently delete the draft." msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/types/delete_draft.py:84 +#: /home/ron/prace/oarepo-requests/oarepo_requests/types/delete_draft.py:84 msgid "Request permission to delete the draft." msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/types/delete_draft.py:88 +#: /home/ron/prace/oarepo-requests/oarepo_requests/types/delete_draft.py:88 msgid "" "Permission to delete draft requested. You will be notified about the " "decision by email." msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/types/delete_draft.py:93 +#: /home/ron/prace/oarepo-requests/oarepo_requests/types/delete_draft.py:93 msgid "" "You have been asked to approve the request to permanently delete the draft. " "You can approve or reject the request." msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/types/delete_draft.py:97 +#: /home/ron/prace/oarepo-requests/oarepo_requests/types/delete_draft.py:97 msgid "Permission to delete draft (including files) requested. " msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/types/delete_draft.py:100 +#: /home/ron/prace/oarepo-requests/oarepo_requests/types/delete_draft.py:100 msgid "Submit request to get permission to delete the draft." msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/types/delete_draft.py:101 +#: /home/ron/prace/oarepo-requests/oarepo_requests/types/delete_draft.py:101 msgid "You do not have permission to delete the draft." msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/types/delete_published_record.py:38 +#: /home/ron/prace/oarepo-requests/oarepo_requests/types/delete_published_record.py:38 msgid "Delete record" msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/types/delete_published_record.py:51 +#: /home/ron/prace/oarepo-requests/oarepo_requests/types/delete_published_record.py:51 msgid "Request deletion of published record" msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/types/delete_published_record.py:68 -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/types/delete_published_record.py:73 +#: /home/ron/prace/oarepo-requests/oarepo_requests/types/delete_published_record.py:68 +#: /home/ron/prace/oarepo-requests/oarepo_requests/types/delete_published_record.py:73 msgid "Request record deletion" msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/types/delete_published_record.py:71 +#: /home/ron/prace/oarepo-requests/oarepo_requests/types/delete_published_record.py:71 msgid "Record deletion requested" msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/types/delete_published_record.py:86 +#: /home/ron/prace/oarepo-requests/oarepo_requests/types/delete_published_record.py:86 msgid "Click to permanently delete the record." msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/types/delete_published_record.py:89 +#: /home/ron/prace/oarepo-requests/oarepo_requests/types/delete_published_record.py:89 msgid "Request permission to delete the record." msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/types/delete_published_record.py:93 +#: /home/ron/prace/oarepo-requests/oarepo_requests/types/delete_published_record.py:93 msgid "" "Permission to delete record requested. You will be notified about the " "decision by email." msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/types/delete_published_record.py:98 +#: /home/ron/prace/oarepo-requests/oarepo_requests/types/delete_published_record.py:98 msgid "" "You have been asked to approve the request to permanently delete the record." " You can approve or reject the request." msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/types/delete_published_record.py:102 +#: /home/ron/prace/oarepo-requests/oarepo_requests/types/delete_published_record.py:102 msgid "Permission to delete record (including files) requested. " msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/types/delete_published_record.py:105 +#: /home/ron/prace/oarepo-requests/oarepo_requests/types/delete_published_record.py:105 msgid "Submit request to get permission to delete the record." msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/types/delete_published_record.py:106 +#: /home/ron/prace/oarepo-requests/oarepo_requests/types/delete_published_record.py:106 msgid "You do not have permission to delete the record." msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/types/edit_record.py:45 +#: /home/ron/prace/oarepo-requests/oarepo_requests/types/edit_record.py:45 msgid "Edit metadata" msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/types/edit_record.py:65 +#: /home/ron/prace/oarepo-requests/oarepo_requests/types/edit_record.py:65 msgid "Request re-opening of published record" msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/types/edit_record.py:122 -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/types/edit_record.py:127 +#: /home/ron/prace/oarepo-requests/oarepo_requests/types/edit_record.py:122 +#: /home/ron/prace/oarepo-requests/oarepo_requests/types/edit_record.py:127 msgid "Request edit access" msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/types/edit_record.py:125 +#: /home/ron/prace/oarepo-requests/oarepo_requests/types/edit_record.py:125 msgid "Edit access requested" msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/types/edit_record.py:140 +#: /home/ron/prace/oarepo-requests/oarepo_requests/types/edit_record.py:140 msgid "Click to start editing the metadata of the record." msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/types/edit_record.py:143 -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/types/edit_record.py:160 +#: /home/ron/prace/oarepo-requests/oarepo_requests/types/edit_record.py:143 +#: /home/ron/prace/oarepo-requests/oarepo_requests/types/edit_record.py:160 msgid "" "Request edit access to the record. You will be notified about the decision " "by email." msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/types/edit_record.py:150 +#: /home/ron/prace/oarepo-requests/oarepo_requests/types/edit_record.py:150 msgid "" "Edit access requested. You will be notified about the decision by email." msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/types/edit_record.py:155 +#: /home/ron/prace/oarepo-requests/oarepo_requests/types/edit_record.py:155 msgid "You have been requested to grant edit access to the record." msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/types/edit_record.py:158 +#: /home/ron/prace/oarepo-requests/oarepo_requests/types/edit_record.py:158 msgid "Edit access requested." msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/types/new_version.py:40 +#: /home/ron/prace/oarepo-requests/oarepo_requests/types/new_version.py:40 msgid "New Version" msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/types/new_version.py:61 +#: /home/ron/prace/oarepo-requests/oarepo_requests/types/new_version.py:61 msgid "Request requesting creation of new version of a published record." msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/types/new_version.py:69 +#: /home/ron/prace/oarepo-requests/oarepo_requests/types/new_version.py:69 msgid "Keep files:" msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/types/new_version.py:70 +#: /home/ron/prace/oarepo-requests/oarepo_requests/types/new_version.py:70 msgid "Keep files in the new version?" msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/types/new_version.py:71 +#: /home/ron/prace/oarepo-requests/oarepo_requests/types/new_version.py:71 msgid "" "If you choose yes, the current record's files will be linked to the new " "version of the record. Then you will be able to add/remove files in the " "form." msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/types/new_version.py:74 +#: /home/ron/prace/oarepo-requests/oarepo_requests/types/new_version.py:74 msgid "No" msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/types/new_version.py:75 +#: /home/ron/prace/oarepo-requests/oarepo_requests/types/new_version.py:75 msgid "Yes" msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/types/new_version.py:123 -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/types/new_version.py:128 +#: /home/ron/prace/oarepo-requests/oarepo_requests/types/new_version.py:123 +#: /home/ron/prace/oarepo-requests/oarepo_requests/types/new_version.py:128 msgid "Request new version access" msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/types/new_version.py:126 +#: /home/ron/prace/oarepo-requests/oarepo_requests/types/new_version.py:126 msgid "New version access requested" msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/types/new_version.py:141 +#: /home/ron/prace/oarepo-requests/oarepo_requests/types/new_version.py:141 msgid "Click to start creating a new version of the record." msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/types/new_version.py:144 +#: /home/ron/prace/oarepo-requests/oarepo_requests/types/new_version.py:144 msgid "" "Request permission to update record (including files). You will be notified " "about the decision by email." msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/types/new_version.py:151 +#: /home/ron/prace/oarepo-requests/oarepo_requests/types/new_version.py:151 msgid "" "Permission to update record (including files) requested. You will be " "notified about the decision by email." msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/types/new_version.py:156 +#: /home/ron/prace/oarepo-requests/oarepo_requests/types/new_version.py:156 msgid "" "You have been asked to approve the request to update the record. You can " "approve or reject the request." msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/types/new_version.py:160 +#: /home/ron/prace/oarepo-requests/oarepo_requests/types/new_version.py:160 msgid "Permission to update record (including files) requested. " msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/types/new_version.py:163 +#: /home/ron/prace/oarepo-requests/oarepo_requests/types/new_version.py:163 msgid "Submit request to get edit access to the record." msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/types/new_version.py:164 +#: /home/ron/prace/oarepo-requests/oarepo_requests/types/new_version.py:164 msgid "You do not have permission to update the record." msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/types/publish_draft.py:46 -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/types/publish_draft.py:128 +#: /home/ron/prace/oarepo-requests/oarepo_requests/types/publish_draft.py:45 +#: /home/ron/prace/oarepo-requests/oarepo_requests/types/publish_draft.py:154 msgid "Publish draft" msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/types/publish_draft.py:63 +#: /home/ron/prace/oarepo-requests/oarepo_requests/types/publish_draft.py:62 msgid "Resource version" msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/types/publish_draft.py:64 +#: /home/ron/prace/oarepo-requests/oarepo_requests/types/publish_draft.py:63 msgid "Write down the version (first, second…)." msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/types/publish_draft.py:79 +#: /home/ron/prace/oarepo-requests/oarepo_requests/types/publish_draft.py:78 msgid "Request publishing of a draft" msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/types/publish_draft.py:130 -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/types/publish_draft.py:135 +#: /home/ron/prace/oarepo-requests/oarepo_requests/types/publish_draft.py:120 +msgid "" +"Missing uploaded files. To disable files for this record please mark it as " +"metadata-only." +msgstr "" + +#: /home/ron/prace/oarepo-requests/oarepo_requests/types/publish_draft.py:124 +msgid "Missing uploaded files." +msgstr "" + +#: /home/ron/prace/oarepo-requests/oarepo_requests/types/publish_draft.py:156 +#: /home/ron/prace/oarepo-requests/oarepo_requests/types/publish_draft.py:161 msgid "Submit for review" msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/types/publish_draft.py:133 +#: /home/ron/prace/oarepo-requests/oarepo_requests/types/publish_draft.py:159 msgid "Submitted for review" msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/types/publish_draft.py:148 +#: /home/ron/prace/oarepo-requests/oarepo_requests/types/publish_draft.py:174 msgid "" "Click to immediately publish the draft. The draft will be a subject to " "embargo as requested in the side panel. Note: The action is irreversible." msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/types/publish_draft.py:155 +#: /home/ron/prace/oarepo-requests/oarepo_requests/types/publish_draft.py:181 msgid "" "By submitting the draft for review you are requesting the publication of the" " draft. The draft will become locked and no further changes will be possible" @@ -449,33 +463,33 @@ msgid "" "decision by email." msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/types/publish_draft.py:163 +#: /home/ron/prace/oarepo-requests/oarepo_requests/types/publish_draft.py:189 msgid "" "The draft has been submitted for review. It is now locked and no further " "changes are possible. You will be notified about the decision by email." msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/types/publish_draft.py:169 +#: /home/ron/prace/oarepo-requests/oarepo_requests/types/publish_draft.py:195 msgid "" "The draft has been submitted for review. You can now accept or decline the " "request." msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/types/publish_draft.py:173 +#: /home/ron/prace/oarepo-requests/oarepo_requests/types/publish_draft.py:199 msgid "The draft has been submitted for review." msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/types/publish_draft.py:176 +#: /home/ron/prace/oarepo-requests/oarepo_requests/types/publish_draft.py:202 msgid "" "Submit for review. After submitting the draft for review, it will be locked " "and no further modifications will be possible." msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/types/publish_draft.py:180 +#: /home/ron/prace/oarepo-requests/oarepo_requests/types/publish_draft.py:206 msgid "Request not yet submitted." msgstr "" -#: /home/dusanst/Projects/oarepo-requests/oarepo_requests/ui/templates/semantic-ui/oarepo_requests_ui/RequestDetail.jinja:3 +#: /home/ron/prace/oarepo-requests/oarepo_requests/ui/templates/semantic-ui/oarepo_requests_ui/RequestDetail.jinja:3 msgid "Request" msgstr "" @@ -491,9 +505,6 @@ msgstr "" msgid "Leave comment" msgstr "" -msgid "Remaining characters: " -msgstr "" - msgid "Request details" msgstr "" diff --git a/tests/test_requests/test_ui_serialialization.py b/tests/test_requests/test_ui_serialialization.py index a10b562..8773754 100644 --- a/tests/test_requests/test_ui_serialialization.py +++ b/tests/test_requests/test_ui_serialialization.py @@ -253,3 +253,32 @@ def current_receiver(record=None, request_type=None, **kwargs): assert ui_record["expanded"]["requests"][0]["receiver"] == role_ui_serialization finally: app.config["OAREPO_REQUESTS_DEFAULT_RECEIVER"] = config_restore + +def test_auto_approve( + vocab_cf, + logged_client, + users, + urls, + new_version_data_function, + record_factory, + search_clear, +): + creator = users[0] + creator_client = logged_client(creator) + + record1 = record_factory(creator.identity) + + resp_request_create = creator_client.post( + urls["BASE_URL_REQUESTS"], + json=new_version_data_function(record1["id"]), + ) + resp_request_submit = creator_client.post( + link_api2testclient(resp_request_create.json["links"]["actions"]["submit"]), + ) + # is request accepted and closed? + request_json = creator_client.get( + f'{urls["BASE_URL_REQUESTS"]}{resp_request_create.json["id"]}', + headers={"Accept": "application/vnd.inveniordm.v1+json"} + ).json + + assert request_json["receiver"]["label"] == "Auto approve" From 7697c25fe970f1c985c7cd323e3c53e5bae49ab3 Mon Sep 17 00:00:00 2001 From: Ronald Krist Date: Mon, 2 Dec 2024 13:41:45 +0100 Subject: [PATCH 2/4] format --- oarepo_requests/config.py | 3 ++- tests/test_requests/test_ui_serialialization.py | 11 ++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/oarepo_requests/config.py b/oarepo_requests/config.py index 279cbd2..840627d 100644 --- a/oarepo_requests/config.py +++ b/oarepo_requests/config.py @@ -21,9 +21,10 @@ WorkflowTransitionComponent, ) from oarepo_requests.resolvers.ui import ( + AutoApproveUIEntityResolver, FallbackEntityReferenceUIResolver, GroupEntityReferenceUIResolver, - UserEntityReferenceUIResolver, AutoApproveUIEntityResolver, + UserEntityReferenceUIResolver, ) from oarepo_requests.types import ( DeletePublishedRecordRequestType, diff --git a/tests/test_requests/test_ui_serialialization.py b/tests/test_requests/test_ui_serialialization.py index 8773754..b2b0e39 100644 --- a/tests/test_requests/test_ui_serialialization.py +++ b/tests/test_requests/test_ui_serialialization.py @@ -13,7 +13,7 @@ from oarepo_requests.resolvers.ui import FallbackEntityReferenceUIResolver -from .utils import is_valid_subdict, link_api2testclient +from .utils import link_api2testclient def test_user_serialization( @@ -175,9 +175,9 @@ def test_resolver_fallback( expected_result = ui_serialization_result( draft_id, ui_record["expanded"]["requests"][0]["id"] ) - expected_result["created_by"]["label"] = ( - f"id: {creator.id}" # the user resolver uses name or email as label, the fallback doesn't know what to use - ) + expected_result["created_by"][ + "label" + ] = f"id: {creator.id}" # the user resolver uses name or email as label, the fallback doesn't know what to use expected_created_by = {**expected_result["created_by"]} actual_created_by = {**ui_record["expanded"]["requests"][0]["created_by"]} @@ -254,6 +254,7 @@ def current_receiver(record=None, request_type=None, **kwargs): finally: app.config["OAREPO_REQUESTS_DEFAULT_RECEIVER"] = config_restore + def test_auto_approve( vocab_cf, logged_client, @@ -278,7 +279,7 @@ def test_auto_approve( # is request accepted and closed? request_json = creator_client.get( f'{urls["BASE_URL_REQUESTS"]}{resp_request_create.json["id"]}', - headers={"Accept": "application/vnd.inveniordm.v1+json"} + headers={"Accept": "application/vnd.inveniordm.v1+json"}, ).json assert request_json["receiver"]["label"] == "Auto approve" From d67cfe84f27dac709aeb94ae3ae643e144e55693 Mon Sep 17 00:00:00 2001 From: Ronald Krist Date: Mon, 2 Dec 2024 13:42:06 +0100 Subject: [PATCH 3/4] version bump --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index bd1ca40..75732f3 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = oarepo-requests -version = 2.3.5 +version = 2.3.6 description = authors = Ronald Krist readme = README.md From 70c558654d76624db0f790f5f543f53cb2df1d77 Mon Sep 17 00:00:00 2001 From: Ronald Krist Date: Mon, 2 Dec 2024 13:42:48 +0100 Subject: [PATCH 4/4] format --- oarepo_requests/resolvers/ui.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/oarepo_requests/resolvers/ui.py b/oarepo_requests/resolvers/ui.py index 9b0477d..8f33695 100644 --- a/oarepo_requests/resolvers/ui.py +++ b/oarepo_requests/resolvers/ui.py @@ -383,7 +383,9 @@ def _search_many( f"No service found for handling reference type {self.reference_type}" ) extra_filter = dsl.Q("terms", **{"id": list(ids)}) - return service.search(identity, extra_filter=extra_filter).to_dict()["hits"]["hits"] + return service.search(identity, extra_filter=extra_filter).to_dict()["hits"][ + "hits" + ] @override def _search_one( @@ -544,6 +546,7 @@ def _get_entity_ui_representation( links=self._extract_links_from_resolved_reference(entity), ) + class KeywordUIEntityResolver(OARepoUIResolver): keyword = None @@ -581,6 +584,7 @@ def _search_one( """ return {self.keyword: _id} + class AutoApproveUIEntityResolver(KeywordUIEntityResolver): keyword = "auto_approve" @@ -601,4 +605,3 @@ def _get_entity_ui_representation( label=_("Auto approve"), links={}, ) -