このコミットが含まれているのは:
@@ -41,7 +41,8 @@ class PostImportsController < ApplicationController
|
||||
end
|
||||
|
||||
def create
|
||||
result = PostImportRunner.new(actor: current_user, rows: params[:rows].to_a).run
|
||||
result = PostImportRunner.new(actor: current_user, rows: params[:rows].to_a,
|
||||
existing: params[:existing]).run
|
||||
render json: result, status: result[:created].positive? ? :created : :ok
|
||||
rescue ArgumentError => e
|
||||
render_bad_request(e.message)
|
||||
@@ -79,7 +80,7 @@ class PostImportsController < ApplicationController
|
||||
|
||||
rows.map do |row|
|
||||
value = ActionController::Parameters.new(row).permit(:source_row, :sourceRow, :url,
|
||||
attributes: {}, provenance: {},
|
||||
attributes: {}, provenance: {}, tag_sources: {},
|
||||
fetch_warnings: [], validation_warnings: [])
|
||||
normalised = value.to_h.deep_transform_keys { _1.to_s.underscore }
|
||||
attributes = normalised.fetch('attributes', { })
|
||||
@@ -90,7 +91,15 @@ class PostImportsController < ApplicationController
|
||||
(provenance.keys - (allowed + ['url'])).empty?
|
||||
raise ArgumentError, '行の形式が不正です.'
|
||||
end
|
||||
unless provenance.values.all? { _1.in?(['automatic', 'mapped', 'fixed', 'manual']) }
|
||||
raise ArgumentError, '値の由来が不正です.'
|
||||
end
|
||||
raise ArgumentError, 'セルが大きすぎます.' if [normalised['url'], *attributes.values].any? { _1.to_s.bytesize > PostImportSourceParser::MAX_CELL_BYTES }
|
||||
if normalised['tag_sources'].present? &&
|
||||
(!normalised['tag_sources'].is_a?(Hash) ||
|
||||
(normalised['tag_sources'].keys - ['automatic', 'mapped', 'fixed', 'manual']).present?)
|
||||
raise ArgumentError, 'タグ由来の形式が不正です.'
|
||||
end
|
||||
|
||||
normalised.symbolize_keys
|
||||
end
|
||||
|
||||
新しい課題から参照
ユーザをブロックする