Skip to content

Commit afd96c7

Browse files
committed
weko#24731 - fixbug when click "Information" of manual file
1 parent c6a3cf8 commit afd96c7

File tree

4 files changed

+16
-10
lines changed

4 files changed

+16
-10
lines changed

modules/weko-deposit/weko_deposit/api.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1340,8 +1340,9 @@ def display_file_info(self):
13401340
exclude_attr = [
13411341
'displaytype', 'accessrole', 'licensetype', 'licensefree']
13421342
filename = request.args.get("filename", None)
1343-
for f in file_metadata:
1344-
if f.get('filename', None) == filename:
1343+
file_order = int(request.args.get("file_order", -1))
1344+
for idx, f in enumerate(file_metadata):
1345+
if file_order == idx or f.get('filename') == filename:
13451346
# Exclude attributes which is not use.
13461347
for ea in exclude_attr:
13471348
if f.get(ea, None):

modules/weko-records-ui/weko_records_ui/templates/weko_records_ui/body_contents.html

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ <h3 class="panel-title">{{_('Item')}}</h3>
9494

9595
{%- set access_permission = record | check_file_permission(file) -%}
9696
{%- set file_details_url = url_for('invenio_records_ui.recid_file_details', pid_value=pid.pid_value,
97-
filename=file.filename) %}
97+
filename=file.filename or '[No FileName]') %}
9898

9999
<tr class="file-row">
100100
<td rowspan="1" class="filecheck-td">
@@ -287,7 +287,11 @@ <h3 class="panel-title">{{_('Item')}}</h3>
287287
{%- endif -%}
288288
{%- endif -%}
289289
<!-- Show button 'Information' -->
290-
{% set file_detail_url = file_details_url + '?filename=' + file.filename %}
290+
{%- if file.filename -%}
291+
{% set file_detail_url = file_details_url + '?filename=' + file.filename %}
292+
{%- else -%}
293+
{% set file_detail_url = file_details_url + '?file_order=' + (loop.index - 1)|string %}
294+
{%- endif -%}
291295
{%- if community -%}
292296
{% set file_detail_url = file_detail_url + "&community=" + community.id %}
293297
{%- endif -%}

modules/weko-records-ui/weko_records_ui/templates/weko_records_ui/file_details_contents.html

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,11 @@ <h2 class="col-sm-12 col-md-12 col-left" style="margin-top: unset;">{{ filename.
4949
{%- set ignore_meta = ('_buckets', '_deposit', '_oai', 'path', 'filemeta', 'item_title', 'item_type_id')
5050
-%}
5151
{%- if files -%}
52-
<!-- Preview Disable Carousel-->
53-
{{ preview_carousel(record=record, files=files, pid=pid, filename=filename, nav=False) }}
52+
{%- if request.args.get("file_order", '-1') == '-1' -%}
53+
<!-- Preview Disable Carousel-->
54+
{{ preview_carousel(record=record, files=files, pid=pid, filename=filename, nav=False) }}
55+
<hr />
56+
{%- endif %}
5457
<hr />
5558
<!-- Details -->
5659
<div class="table-responsive">

modules/weko-records-ui/weko_records_ui/utils.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -591,11 +591,9 @@ def set_message_for_file(p_file):
591591
if check_file_download_permission(record, f, True)\
592592
or is_open_restricted(f):
593593
# Set default version_id.
594-
if f.get("version_id") is None:
595-
f["version_id"] = ''
594+
f["version_id"] = f.get('version_id', '')
596595
# Set is_thumbnail flag.
597-
if f.get("is_thumbnail") is None:
598-
f["is_thumbnail"] = False
596+
f["is_thumbnail"] = f.get('is_thumbnail', False)
599597
# Check Opendate is future date.
600598
set_message_for_file(f)
601599
# Check show preview area.

0 commit comments

Comments
 (0)