Skip to content

Commit

Permalink
fix: no permissions for files caused the detail page to fail (#260)
Browse files Browse the repository at this point in the history
  • Loading branch information
mesemus authored Nov 29, 2024
1 parent bc3a39b commit e8a26fe
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
12 changes: 10 additions & 2 deletions oarepo_ui/resources/components/files.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from invenio_records_resources.services.errors import PermissionDeniedError

from oarepo_runtime.datastreams.utils import get_file_service_for_record_service

from .base import UIResourceComponent
Expand All @@ -13,8 +15,14 @@ def before_ui_edit(self, *, api_record, extra_context, identity, **kwargs):
file_service = get_file_service_for_record_service(
self.resource.api_service, record=api_record
)
files = file_service.list_files(identity, api_record["id"])
extra_context["files"] = files.to_dict()
try:
files = file_service.list_files(identity, api_record["id"])
extra_context["files"] = files.to_dict()
except PermissionDeniedError:
extra_context["files"] = {
"entries": [],
"links": {}
}

def before_ui_detail(self, **kwargs):
self.before_ui_edit(**kwargs)
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = oarepo-ui
version = 5.2.28
version = 5.2.29
description = UI module for invenio 3.5+
long_description = file: README.md
long_description_content_type = text/markdown
Expand Down

0 comments on commit e8a26fe

Please sign in to comment.