Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

errors: add error handler for community submission closed #592

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions invenio_records_resources/resources/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
PermissionDeniedError,
QuerystringValidationError,
RecordPermissionDeniedError,
RecordSubmissionClosedCommunityError,
RevisionIdMismatchError,
)

Expand Down Expand Up @@ -207,4 +208,10 @@ class ErrorHandlersMixin:
description="Uploading selected files will result in exceeding the max amount per record.",
)
),
RecordSubmissionClosedCommunityError: create_error_handler(
lambda e: HTTPJSONException(
code=403,
description=e.description,
)
),
}
6 changes: 6 additions & 0 deletions invenio_records_resources/services/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,9 @@ def __init__(self, max_files, resulting_files_count):
)
)
)


class RecordSubmissionClosedCommunityError(PermissionDenied):
"""Record submission policy forbids non-members from submitting records to community."""

description = "Submission to this community is only allowed to community members."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor: invenio-records-resources is too low in the dependency chain to know about communities. Shouldn't this be in a module further up the chain?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 for this, there shouldn't be any references to communities in the records-resources modules, since communities depends on records-resources, not the other way around

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved changes to inveniosoftware/invenio-rdm-records#1790
closing this PR