mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-02-06 06:56:54 +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
|
||||
# assign it to result
|
||||
validate :step_or_result_or_repository_asset_value
|
||||
validate :name_should_not_be_empty_without_extension,
|
||||
on: :wopi_file_creation
|
||||
|
||||
belongs_to :created_by,
|
||||
foreign_key: 'created_by_id',
|
||||
|
@ -517,6 +519,15 @@ class Asset < ApplicationRecord
|
|||
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
|
||||
fetched_file = file.fetch
|
||||
file_content = fetched_file.read
|
||||
|
|
Loading…
Reference in a new issue