Skip to content

Commit

Permalink
Merge pull request #248 from oarepo/miroslavsimek/be-521-file-preview…
Browse files Browse the repository at this point in the history
…-does-not-work-on-preview-page

hack: Hacked file preview to work on record preview page
  • Loading branch information
mirekys authored Oct 31, 2024
2 parents 8cfeb96 + 5353f74 commit dce9f48
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion oarepo_ui/resources/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,13 @@ def detail(self):
def file_preview(self, *args, is_preview=False, **kwargs):
pid_value = resource_requestctx.view_args["pid_value"]
filepath = resource_requestctx.view_args["filepath"]
record = self._get_record(resource_requestctx, allow_draft=is_preview)._record

# TODO: this is a hack that should be fixed
try:
record = self._get_record(resource_requestctx, allow_draft=is_preview)._record
except Forbidden:
record = self._get_record(resource_requestctx, allow_draft=not is_preview)._record

file_service = get_file_service_for_record_class(type(record))
file_metadata = file_service.read_file_metadata(g.identity, pid_value, filepath)

Expand Down
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.21
version = 5.2.22
description = UI module for invenio 3.5+
long_description = file: README.md
long_description_content_type = text/markdown
Expand Down

0 comments on commit dce9f48

Please sign in to comment.