-
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.
- Loading branch information
Ronald Krist
committed
Jan 11, 2024
1 parent
6530247
commit 10acf8b
Showing
22 changed files
with
511 additions
and
116 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
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,20 @@ | ||
class OpenRequestAlreadyExists(Exception): | ||
"""An open request already exists.""" | ||
|
||
def __init__(self, request, record): | ||
self.request = request | ||
self.record = record | ||
|
||
@property | ||
def description(self): | ||
"""Exception's description.""" | ||
return f"There is already an open request of {self.request.name} on {self.record.id}." | ||
|
||
class UnknownRequestType(Exception): | ||
def __init__(self, request_type): | ||
self.request_type = request_type | ||
|
||
@property | ||
def description(self): | ||
"""Exception's description.""" | ||
return f"Unknown request type {self.request_type}." |
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,10 +1,12 @@ | ||
from invenio_records_resources.resources.records.config import RecordResourceConfig | ||
from invenio_records_resources.services.base.config import ConfiguratorMixin | ||
|
||
|
||
class OARepoRequestsResourceConfig(RecordResourceConfig, ConfiguratorMixin): | ||
"""""" | ||
|
||
blueprint_name = "oarepo-requests" | ||
url_prefix = "/requests" | ||
routes = { | ||
"create": "/create", | ||
} | ||
"list": "/", | ||
} |
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,40 @@ | ||
from invenio_records_resources.services.uow import unit_of_work | ||
|
||
from oarepo_requests.errors import UnknownRequestType | ||
from invenio_requests.proxies import current_request_type_registry | ||
|
||
|
||
class CreateRequestsService: | ||
def __init__(self, requests_service): | ||
self.requests_service = requests_service | ||
|
||
@unit_of_work() | ||
def create( | ||
self, | ||
identity, | ||
data, | ||
request_type, | ||
receiver, | ||
creator=None, | ||
topic=None, | ||
expires_at=None, | ||
uow=None, | ||
expand=False, | ||
): | ||
type_ = current_request_type_registry.lookup(request_type, quiet=True) | ||
if not type_: | ||
raise UnknownRequestType(request_type) | ||
if hasattr(type_, "can_create"): | ||
error = type_.can_create(identity, data, receiver, topic, creator) | ||
else: | ||
error = None | ||
if not error: | ||
return self.requests_service.create( | ||
identity=identity, | ||
data=data, | ||
request_type=type_, | ||
receiver=receiver, | ||
creator=creator, | ||
topic=topic, | ||
expand=expand, | ||
) |
This file was deleted.
Oops, something went wrong.
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,12 +1,18 @@ | ||
from invenio_requests.customizations import RequestType | ||
from invenio_requests.proxies import current_requests_service | ||
|
||
from oarepo_requests.actions.delete_topic import DeleteTopicSubmitAction | ||
from oarepo_requests.actions.delete_topic import DeleteTopicAcceptAction | ||
from oarepo_requests.errors import OpenRequestAlreadyExists | ||
from .generic import OARepoRequestType | ||
from oarepo_requests.utils import open_request_exists, resolve_reference_dict | ||
from invenio_records_resources.services.errors import PermissionDeniedError | ||
|
||
|
||
class DeleteRecordRequestType(RequestType): | ||
class DeleteRecordRequestType(OARepoRequestType): | ||
available_actions = { | ||
**RequestType.available_actions, | ||
"submit": DeleteTopicSubmitAction, | ||
"accept": DeleteTopicAcceptAction, | ||
} | ||
|
||
receiver_can_be_none = True | ||
|
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,4 +1,4 @@ | ||
def create_oarepo_requests(app): | ||
"""Create requests blueprint.""" | ||
ext = app.extensions["oarepo-requests"] | ||
return ext.requests_resource.as_blueprint() | ||
return ext.requests_resource.as_blueprint() |
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
Oops, something went wrong.