-
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 #27 from oarepo/generic-topics-receivers
Using one request type for all topics
- Loading branch information
Showing
12 changed files
with
126 additions
and
17 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,28 @@ | ||
from oarepo_requests.resolvers.ui import UserEntityReferenceUIResolver, FallbackEntityReferenceUIResolver, \ | ||
GroupEntityReferenceUIResolver | ||
from oarepo_requests.types import DeletePublishedRecordRequestType, EditPublishedRecordRequestType, PublishDraftRequestType | ||
from invenio_users_resources.entity_resolvers import UserResolver, GroupResolver | ||
|
||
|
||
REQUESTS_REGISTERED_TYPES = [ | ||
DeletePublishedRecordRequestType(), | ||
EditPublishedRecordRequestType(), | ||
PublishDraftRequestType(), | ||
] | ||
|
||
REQUESTS_ALLOWED_RECEIVERS = [ | ||
"user", "role" | ||
] | ||
|
||
REQUESTS_ENTITY_RESOLVERS = [ | ||
UserResolver(), | ||
GroupResolver(), | ||
] | ||
|
||
ENTITY_REFERENCE_UI_RESOLVERS = { | ||
"user": UserEntityReferenceUIResolver("user"), | ||
"fallback": FallbackEntityReferenceUIResolver("fallback"), | ||
"group": GroupEntityReferenceUIResolver("group"), | ||
} | ||
|
||
REQUESTS_UI_SERIALIZATION_REFERENCED_FIELDS = ["created_by", "receiver", "topic"] |
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,14 @@ | ||
from .ref_types import ModelRefTypes, ReceiverRefTypes | ||
from .delete_record import DeletePublishedRecordRequestType | ||
from .edit_record import EditPublishedRecordRequestType | ||
from .publish_draft import PublishDraftRequestType | ||
from .generic import NonDuplicableOARepoRequestType | ||
|
||
__all__ = [ | ||
'ModelRefTypes', | ||
'ReceiverRefTypes', | ||
'DeletePublishedRecordRequestType', | ||
'EditPublishedRecordRequestType', | ||
'PublishDraftRequestType', | ||
'NonDuplicableOARepoRequestType', | ||
] |
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
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,23 @@ | ||
from oarepo_requests.proxies import current_oarepo_requests | ||
|
||
|
||
class ModelRefTypes: | ||
""" | ||
This class is used to define the allowed reference types for the topic reference. | ||
The list of ref types is taken from the configuration (configuration key REQUESTS_ALLOWED_TOPICS). | ||
""" | ||
|
||
def __get__(self, obj, owner): | ||
"""Property getter, returns the list of allowed reference types.""" | ||
return current_oarepo_requests.allowed_topic_ref_types | ||
|
||
|
||
class ReceiverRefTypes: | ||
""" | ||
This class is used to define the allowed reference types for the receiver reference. | ||
The list of ref types is taken from the configuration (configuration key REQUESTS_ALLOWED_RECEIVERS). | ||
""" | ||
|
||
def __get__(self, obj, owner): | ||
"""Property getter, returns the list of allowed reference types.""" | ||
return current_oarepo_requests.allowed_receiver_ref_types |
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,6 +1,6 @@ | ||
[metadata] | ||
name = oarepo-requests | ||
version = 1.1.18 | ||
version = 1.1.19 | ||
description = | ||
authors = Ronald Krist <[email protected]> | ||
readme = README.md | ||
|
@@ -47,3 +47,7 @@ invenio_assets.webpack = | |
oarepo_requests_ui_theme = oarepo_requests.ui.theme.webpack:theme | ||
invenio_i18n.translations = | ||
oarepo_requests_ui = oarepo_requests | ||
invenio_requests.types = | ||
delete-published-record = oarepo_requests.types.delete_record:DeletePublishedRecordRequestType | ||
edit-published-record = oarepo_requests.types.edit_record:EditPublishedRecordRequestType | ||
publish-draft = oarepo_requests.types.publish_draft:PublishDraftRequestType |
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