mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-12-25 17:24:51 +08:00
Fix link to original file in docx protocol parser notification [SCI-9123] (#6070)
This commit is contained in:
parent
0faad52f6c
commit
c1e2128b04
2 changed files with 13 additions and 7 deletions
|
@ -31,6 +31,8 @@ module ActiveStorage
|
||||||
true
|
true
|
||||||
when 'ZipExport', 'TeamZipExport'
|
when 'ZipExport', 'TeamZipExport'
|
||||||
check_zip_export_read_permissions(attachment.record)
|
check_zip_export_read_permissions(attachment.record)
|
||||||
|
when 'TempFile'
|
||||||
|
check_temp_file_read_permissions(attachment.record)
|
||||||
else
|
else
|
||||||
render_403
|
render_403
|
||||||
end
|
end
|
||||||
|
@ -87,5 +89,9 @@ module ActiveStorage
|
||||||
def check_zip_export_read_permissions(zip_export)
|
def check_zip_export_read_permissions(zip_export)
|
||||||
render_403 unless zip_export.user == current_user
|
render_403 unless zip_export.user == current_user
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def check_temp_file_read_permissions(temp_file)
|
||||||
|
render_403 unless temp_file.session_id == request.session_options[:id].to_s
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -9,7 +9,8 @@ module Protocols
|
||||||
def perform(temp_files_ids, user_id, team_id)
|
def perform(temp_files_ids, user_id, team_id)
|
||||||
@user = User.find(user_id)
|
@user = User.find(user_id)
|
||||||
@team = @user.teams.find(team_id)
|
@team = @user.teams.find(team_id)
|
||||||
TempFile.where(id: temp_files_ids).each do |temp_file|
|
@tmp_files = TempFile.where(id: temp_files_ids)
|
||||||
|
@tmp_files.each do |temp_file|
|
||||||
temp_file.file.open do |protocol_file|
|
temp_file.file.open do |protocol_file|
|
||||||
parse_protocol(protocol_file)
|
parse_protocol(protocol_file)
|
||||||
end
|
end
|
||||||
|
@ -135,15 +136,14 @@ module Protocols
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_notification!
|
def create_notification!
|
||||||
# TODO: Add proper protocol original file link
|
original_file_download_link =
|
||||||
protocol_download_link = "<a data-id='#{@protocol.id}' " \
|
"<a data-turbolinks='false' " \
|
||||||
"data-turbolinks='false' " \
|
"href='#{Rails.application.routes.url_helpers.rails_blob_path(@tmp_files.take.file)}'>" \
|
||||||
"href='#'>" \
|
"#{@tmp_files.take.file.filename}</a>"
|
||||||
"#{@protocol.name}</a>"
|
|
||||||
|
|
||||||
notification = Notification.create!(
|
notification = Notification.create!(
|
||||||
type_of: :deliver,
|
type_of: :deliver,
|
||||||
title: I18n.t('protocols.import_export.import_protocol_notification.title', link: protocol_download_link),
|
title: I18n.t('protocols.import_export.import_protocol_notification.title', link: original_file_download_link),
|
||||||
message: "#{I18n.t('protocols.import_export.import_protocol_notification.message')} " \
|
message: "#{I18n.t('protocols.import_export.import_protocol_notification.message')} " \
|
||||||
"<a data-id='#{@protocol.id}' data-turbolinks='false' " \
|
"<a data-id='#{@protocol.id}' data-turbolinks='false' " \
|
||||||
"href='#{Rails.application.routes.url_helpers.protocol_path(@protocol)}'>" \
|
"href='#{Rails.application.routes.url_helpers.protocol_path(@protocol)}'>" \
|
||||||
|
|
Loading…
Reference in a new issue