このコミットが含まれているのは:
@@ -7,6 +7,7 @@ class PostImportPreviewer
|
||||
'thumbnail_base',
|
||||
'original_created_from',
|
||||
'original_created_before',
|
||||
'video_ms',
|
||||
'duration',
|
||||
'tags',
|
||||
'parent_post_ids'].freeze
|
||||
@@ -162,6 +163,8 @@ class PostImportPreviewer
|
||||
normalised =
|
||||
if field == 'duration'
|
||||
normalise_duration_attribute(value)
|
||||
elsif field == 'video_ms'
|
||||
value.nil? ? '' : value.to_s
|
||||
else
|
||||
value.to_s
|
||||
end
|
||||
@@ -194,7 +197,7 @@ class PostImportPreviewer
|
||||
|
||||
def clear_automatic_values! attributes, provenance, tag_sources
|
||||
['title', 'thumbnail_base', 'original_created_from',
|
||||
'original_created_before', 'duration'].each do |field|
|
||||
'original_created_before', 'video_ms', 'duration'].each do |field|
|
||||
attributes[field] = '' if provenance[field] == 'automatic'
|
||||
end
|
||||
tag_sources['automatic'] = ''
|
||||
@@ -466,7 +469,7 @@ class PostImportPreviewer
|
||||
thumbnail_base: attributes['thumbnail_base'].presence,
|
||||
original_created_from: attributes['original_created_from'].presence,
|
||||
original_created_before: attributes['original_created_before'].presence,
|
||||
video_ms: parse_duration(attributes['duration'], errors))
|
||||
video_ms: parse_video_ms(attributes, errors))
|
||||
post.valid?
|
||||
post.errors.each do |error|
|
||||
next if error.attribute == :url && error.type == :taken
|
||||
@@ -475,7 +478,19 @@ class PostImportPreviewer
|
||||
end
|
||||
end
|
||||
|
||||
def parse_duration value, errors
|
||||
def parse_video_ms attributes, errors
|
||||
video_ms = attributes['video_ms']
|
||||
if video_ms.present?
|
||||
value = Integer(video_ms, exception: false)
|
||||
if value&.positive?
|
||||
return value
|
||||
end
|
||||
|
||||
errors[:video_ms] = ['動画時間の記法が不正です.']
|
||||
return nil
|
||||
end
|
||||
|
||||
value = attributes['duration']
|
||||
return nil if value.blank?
|
||||
|
||||
Tag.time_to_ms!(value.to_s, tag_name: '動画時間')
|
||||
|
||||
新しい課題から参照
ユーザをブロックする