mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-02-24 15:54:00 +08:00
Move edit_file permission for wopi file in a special function
Used for overwritting it in addons. Closes SCI-2949
This commit is contained in:
parent
bb29a97962
commit
eceda4909f
1 changed files with 20 additions and 14 deletions
|
@ -78,20 +78,7 @@ class AssetsController < ApplicationController
|
||||||
elsif @assoc.class == RepositoryCell
|
elsif @assoc.class == RepositoryCell
|
||||||
can_manage_repository_rows?(@repository.team)
|
can_manage_repository_rows?(@repository.team)
|
||||||
end
|
end
|
||||||
file_ext = @asset.file_file_name.split('.').last
|
edit_supported, title = wopi_file_edit_button_status
|
||||||
if Constants::WOPI_EDITABLE_FORMATS.include?(file_ext)
|
|
||||||
edit_supported = true
|
|
||||||
title = ''
|
|
||||||
else
|
|
||||||
edit_supported = false
|
|
||||||
title = if Constants::FILE_TEXT_FORMATS.include?(file_ext)
|
|
||||||
I18n.t('assets.wopi_supported_text_formats_title')
|
|
||||||
elsif Constants::FILE_TABLE_FORMATS.include?(file_ext)
|
|
||||||
I18n.t('assets.wopi_supported_table_formats_title')
|
|
||||||
else
|
|
||||||
I18n.t('assets.wopi_supported_presentation_formats_title')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
response_json['wopi-controls'] = render_to_string(
|
response_json['wopi-controls'] = render_to_string(
|
||||||
partial: 'shared/file_wopi_controlls.html.erb',
|
partial: 'shared/file_wopi_controlls.html.erb',
|
||||||
locals: {
|
locals: {
|
||||||
|
@ -109,6 +96,25 @@ class AssetsController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Check whether the wopi file can be edited and return appropriate response
|
||||||
|
def wopi_file_edit_button_status
|
||||||
|
file_ext = @asset.file_file_name.split('.').last
|
||||||
|
if Constants::WOPI_EDITABLE_FORMATS.include?(file_ext)
|
||||||
|
edit_supported = true
|
||||||
|
title = ''
|
||||||
|
else
|
||||||
|
edit_supported = false
|
||||||
|
title = if Constants::FILE_TEXT_FORMATS.include?(file_ext)
|
||||||
|
I18n.t('assets.wopi_supported_text_formats_title')
|
||||||
|
elsif Constants::FILE_TABLE_FORMATS.include?(file_ext)
|
||||||
|
I18n.t('assets.wopi_supported_table_formats_title')
|
||||||
|
else
|
||||||
|
I18n.t('assets.wopi_supported_presentation_formats_title')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return edit_supported, title
|
||||||
|
end
|
||||||
|
|
||||||
def download
|
def download
|
||||||
if !@asset.file_present
|
if !@asset.file_present
|
||||||
render_404 and return
|
render_404 and return
|
||||||
|
|
Loading…
Reference in a new issue