mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-03-01 02:05:41 +08:00
Fix new office file creation [SCI-3778]
This commit is contained in:
parent
6fda5401f5
commit
3918c893db
4 changed files with 8 additions and 11 deletions
|
@ -56,14 +56,15 @@ module Api
|
||||||
raise ActiveRecord::RecordInvalid,
|
raise ActiveRecord::RecordInvalid,
|
||||||
I18n.t('api.core.errors.result_wrong_tinymce.detail')
|
I18n.t('api.core.errors.result_wrong_tinymce.detail')
|
||||||
end
|
end
|
||||||
image = Paperclip.io_adapters.for(image_params[:file_data])
|
|
||||||
image.original_filename = image_params[:file_name]
|
|
||||||
tiny_image = TinyMceAsset.create!(
|
tiny_image = TinyMceAsset.create!(
|
||||||
image: image,
|
|
||||||
team: @team,
|
team: @team,
|
||||||
object: result_text,
|
object: result_text,
|
||||||
saved: true
|
saved: true
|
||||||
)
|
)
|
||||||
|
tiny_image.image.attach(
|
||||||
|
io: StringIO.new(Base64.decode64(image_params[:file_data].split(',')[1])),
|
||||||
|
filename: image_params[:file_name]
|
||||||
|
)
|
||||||
result_text.text.sub!("data-mce-token=\"#{token}\"", "data-mce-token=\"#{Base62.encode(tiny_image.id)}\"")
|
result_text.text.sub!("data-mce-token=\"#{token}\"", "data-mce-token=\"#{Base62.encode(tiny_image.id)}\"")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -209,7 +209,7 @@ class AssetsController < ApplicationController
|
||||||
render_403 and return unless can_manage_module?(my_module)
|
render_403 and return unless can_manage_module?(my_module)
|
||||||
|
|
||||||
# First create result and then the asset
|
# First create result and then the asset
|
||||||
result = Result.create(name: file.original_filename,
|
result = Result.create(name: asset.file_name,
|
||||||
my_module: my_module,
|
my_module: my_module,
|
||||||
user: current_user)
|
user: current_user)
|
||||||
result_asset = ResultAsset.create!(result: result, asset: asset)
|
result_asset = ResultAsset.create!(result: result, asset: asset)
|
||||||
|
|
|
@ -437,9 +437,7 @@ class Asset < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def update_contents(new_file)
|
def update_contents(new_file)
|
||||||
new_file.class.class_eval { attr_accessor :original_filename }
|
file.attach(io: new_file, filename: file_name)
|
||||||
new_file.original_filename = file_name
|
|
||||||
file.attach(io: new_file, filename: original_filename)
|
|
||||||
self.version = version.nil? ? 1 : version + 1
|
self.version = version.nil? ? 1 : version + 1
|
||||||
save
|
save
|
||||||
end
|
end
|
||||||
|
@ -473,14 +471,14 @@ class Asset < ApplicationRecord
|
||||||
|
|
||||||
def wopi_filename_valid
|
def wopi_filename_valid
|
||||||
# Check that filename without extension is not blank
|
# Check that filename without extension is not blank
|
||||||
unless file.original_filename[0..-6].present?
|
unless file_name[0..-6].present?
|
||||||
errors.add(
|
errors.add(
|
||||||
:file,
|
:file,
|
||||||
I18n.t('general.text.not_blank')
|
I18n.t('general.text.not_blank')
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
# Check maximum filename length
|
# Check maximum filename length
|
||||||
if file.original_filename.length > Constants::FILENAME_MAX_LENGTH
|
if file_name.length > Constants::FILENAME_MAX_LENGTH
|
||||||
errors.add(
|
errors.add(
|
||||||
:file,
|
:file,
|
||||||
I18n.t(
|
I18n.t(
|
||||||
|
|
|
@ -14,8 +14,6 @@ Api.configure do |config|
|
||||||
|
|
||||||
config.core_api_v1_enabled = true if ENV['CORE_API_V1_ENABLED']
|
config.core_api_v1_enabled = true if ENV['CORE_API_V1_ENABLED']
|
||||||
|
|
||||||
Paperclip::DataUriAdapter.register if ENV['CORE_API_V1_ENABLED']
|
|
||||||
|
|
||||||
vars = ENV.select { |name, _| name =~ /^[[:alnum:]]*_AZURE_AD_APP_ID/ }
|
vars = ENV.select { |name, _| name =~ /^[[:alnum:]]*_AZURE_AD_APP_ID/ }
|
||||||
vars.each do |name, value|
|
vars.each do |name, value|
|
||||||
app_name = name.sub('_AZURE_AD_APP_ID', '')
|
app_name = name.sub('_AZURE_AD_APP_ID', '')
|
||||||
|
|
Loading…
Reference in a new issue