mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-13 08:34:49 +08:00
Fix file URL generation on shared task page [SCI-8974]
This commit is contained in:
parent
b264bfab68
commit
c61a075818
5 changed files with 11 additions and 9 deletions
|
@ -68,7 +68,8 @@ class MyModuleShareableLinksController < ApplicationController
|
|||
end
|
||||
|
||||
def download_asset
|
||||
redirect_to @asset.file.url(disposition: 'attachment')
|
||||
redirect_to @asset.file.url(expires_in: Constants::URL_SHORT_EXPIRE_TIME.minutes, disposition: 'attachment'),
|
||||
allow_other_host: true
|
||||
end
|
||||
|
||||
def create
|
||||
|
@ -119,9 +120,7 @@ class MyModuleShareableLinksController < ApplicationController
|
|||
end
|
||||
|
||||
def load_asset
|
||||
@asset = Asset.joins(step: { protocol: :my_module })
|
||||
.find_by(my_modules: { id: @my_module.id },
|
||||
assets: { id: params[:id] })
|
||||
@asset = @my_module.assets_in_steps.find_by(id: params[:id])
|
||||
|
||||
return render_404 if @asset.blank?
|
||||
end
|
||||
|
|
|
@ -69,6 +69,9 @@ class MyModule < ApplicationRecord
|
|||
has_many :designated_users, through: :user_my_modules, source: :user
|
||||
has_many :report_elements, inverse_of: :my_module, dependent: :destroy
|
||||
has_many :protocols, inverse_of: :my_module, dependent: :destroy
|
||||
has_many :steps, through: :protocols
|
||||
has_many :assets_in_steps, class_name: 'Asset', source: :assets, through: :steps
|
||||
has_many :assets_in_results, class_name: 'Asset', source: :asset, through: :results
|
||||
# Associations for old activity type
|
||||
has_many :activities, inverse_of: :my_module
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="file-preview-container">
|
||||
<% if asset.previewable? %>
|
||||
<% if asset.previewable? && !asset.file_processing %>
|
||||
<% if wopi_enabled? && wopi_file?(asset) %>
|
||||
<iframe class="wopi-file-preview" src="<%= asset.get_action_url(nil, 'embedview', false) %>"></iframe>
|
||||
<% elsif asset.pdf_previewable? %>
|
||||
|
@ -46,7 +46,7 @@
|
|||
class: "previous-asset shareable-gallery-switcher",
|
||||
data: { id: previous_asset.id } do %>
|
||||
<i class="sn-icon sn-icon-arrow-left"></i>
|
||||
<% if previous_asset.previewable? %>
|
||||
<% if previous_asset.previewable? && !previous_asset.file_processing %>
|
||||
<%= image_tag previous_asset.file.representation(resize_to_limit: Constants::MEDIUM_PIC_FORMAT).url(expires_in: Constants::URL_SHORT_EXPIRE_TIME.minutes),
|
||||
class: 'asset-image',
|
||||
style: 'opacity: 0' %>
|
||||
|
@ -63,7 +63,7 @@
|
|||
<%= link_to '#',
|
||||
class: "next-asset shareable-gallery-switcher",
|
||||
data: { id: next_asset.id } do %>
|
||||
<% if next_asset.previewable? %>
|
||||
<% if next_asset.previewable? && !next_asset.file_processing %>
|
||||
<%= image_tag next_asset.file.representation(resize_to_limit: Constants::MEDIUM_PIC_FORMAT).url(expires_in: Constants::URL_SHORT_EXPIRE_TIME.minutes),
|
||||
class: 'asset-image',
|
||||
style: 'opacity: 0' %>
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
<iframe class="wopi-file-preview" src="<%= asset.get_action_url(nil, 'embedview', false) %>"></iframe>
|
||||
<% elsif asset.pdf_previewable? %>
|
||||
<%= render partial: 'shared/pdf_viewer', locals: { asset: asset, report_document: false, shareable_document: true } %>
|
||||
<% elsif asset.previewable? %>
|
||||
<% elsif asset.previewable? && !asset.file_processing %>
|
||||
<div class="image-container">
|
||||
<%= image_tag asset.file.representation(resize_to_limit: Constants::LARGE_PIC_FORMAT).url(expires_in: Constants::URL_SHORT_EXPIRE_TIME.minutes),
|
||||
class: 'asset-preview-image',
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
id: asset.id
|
||||
} do %>
|
||||
<div class="attachment-preview <%= asset.file.attached? ? asset.file.metadata['asset_type'] : '' %>">
|
||||
<% if asset.previewable? %>
|
||||
<% if asset.previewable? && !asset.file_processing %>
|
||||
<%= image_tag asset.file.representation(resize_to_limit: Constants::MEDIUM_PIC_FORMAT).url(expires_in: Constants::URL_SHORT_EXPIRE_TIME.minutes),
|
||||
class: 'asset-preview-image',
|
||||
style: 'opacity: 0' %>
|
||||
|
|
Loading…
Add table
Reference in a new issue