-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #85 from oarepo/krist/be-492-expand-on-request-ins…
…tance-seems-not-to-work-for-lter Krist/be 492 expand on request instance seems not to work for lter
- Loading branch information
Showing
132 changed files
with
4,025 additions
and
1,263 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Copyright (C) 2024 CESNET z.s.p.o. | ||
|
||
oarepo-requests is free software; you can redistribute it and/or | ||
modify it under the terms of the MIT License; see LICENSE file for more | ||
details. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[report] | ||
exclude_lines = | ||
pragma: no cover | ||
^# | ||
exclude_also = | ||
if TYPE_CHECKING: | ||
if __name__ == .__main__.: | ||
if TYPE_CHECKING: | ||
class .*\bProtocol\): | ||
@(abc\.)?abstractmethod | ||
raise AssertionError | ||
raise NotImplementedError |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[mypy] | ||
disable_error_code = import-untyped, import-not-found |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# | ||
# Copyright (C) 2024 CESNET z.s.p.o. | ||
# | ||
# oarepo-requests is free software; you can redistribute it and/or | ||
# modify it under the terms of the MIT License; see LICENSE file for more | ||
# details. | ||
# | ||
"""Invenio extension for better handling of requests.""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# | ||
# Copyright (C) 2024 CESNET z.s.p.o. | ||
# | ||
# oarepo-requests is free software; you can redistribute it and/or | ||
# modify it under the terms of the MIT License; see LICENSE file for more | ||
# details. | ||
# | ||
"""Request actions.""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,43 @@ | ||
# | ||
# Copyright (C) 2024 CESNET z.s.p.o. | ||
# | ||
# oarepo-requests is free software; you can redistribute it and/or | ||
# modify it under the terms of the MIT License; see LICENSE file for more | ||
# details. | ||
# | ||
"""Actions for delete draft record request.""" | ||
|
||
from __future__ import annotations | ||
|
||
from typing import TYPE_CHECKING, Any, override | ||
|
||
from oarepo_runtime.datastreams.utils import get_record_service_for_record | ||
|
||
from .cascade_events import cancel_requests_on_topic_delete | ||
from .generic import OARepoAcceptAction | ||
|
||
if TYPE_CHECKING: | ||
from flask_principal import Identity | ||
from invenio_drafts_resources.records import Record | ||
from invenio_records_resources.services.uow import UnitOfWork | ||
from invenio_requests.customizations import RequestType | ||
|
||
|
||
class DeleteDraftAcceptAction(OARepoAcceptAction): | ||
def apply(self, identity, request_type, topic, uow, *args, **kwargs): | ||
"""Accept request for deletion of a draft record and delete the record.""" | ||
|
||
@override | ||
def apply( | ||
self, | ||
identity: Identity, | ||
request_type: RequestType, | ||
topic: Record, | ||
uow: UnitOfWork, | ||
*args: Any, | ||
**kwargs: Any, | ||
) -> None: | ||
topic_service = get_record_service_for_record(topic) | ||
if not topic_service: | ||
raise KeyError(f"topic {topic} service not found") | ||
topic_service.delete_draft(identity, topic["id"], uow=uow, *args, **kwargs) | ||
topic_service.delete_draft(identity, topic["id"], *args, uow=uow, **kwargs) | ||
cancel_requests_on_topic_delete(self.request, topic, uow) |
Oops, something went wrong.