mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-02-06 15:05:26 +08:00
Add asset validation on wopi creation
Missing file
This commit is contained in:
parent
d9a9045658
commit
bc9eff2ef5
1 changed files with 11 additions and 0 deletions
|
@ -47,6 +47,8 @@ class Asset < ApplicationRecord
|
||||||
# This could cause some problems if you create empty asset and want to
|
# This could cause some problems if you create empty asset and want to
|
||||||
# assign it to result
|
# assign it to result
|
||||||
validate :step_or_result_or_repository_asset_value
|
validate :step_or_result_or_repository_asset_value
|
||||||
|
validate :name_should_not_be_empty_without_extension,
|
||||||
|
on: :wopi_file_creation
|
||||||
|
|
||||||
belongs_to :created_by,
|
belongs_to :created_by,
|
||||||
foreign_key: 'created_by_id',
|
foreign_key: 'created_by_id',
|
||||||
|
@ -517,6 +519,15 @@ class Asset < ApplicationRecord
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def name_should_not_be_empty_without_extension
|
||||||
|
unless file.original_filename[0..-6].present?
|
||||||
|
errors.add(
|
||||||
|
:file,
|
||||||
|
I18n.t('general.text.not_blank')
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def cache
|
def cache
|
||||||
fetched_file = file.fetch
|
fetched_file = file.fetch
|
||||||
file_content = fetched_file.read
|
file_content = fetched_file.read
|
||||||
|
|
Loading…
Reference in a new issue