Fix various issues with domain block import (#1944)
- stop using Paperclip for processing domain allow/block imports - stop leaving temporary files - better error handling - assume CSV files are UTF-8-encoded
This commit is contained in:
@ -8,8 +8,6 @@ module Admin
|
||||
|
||||
before_action :set_dummy_import!, only: [:new]
|
||||
|
||||
ROWS_PROCESSING_LIMIT = 20_000
|
||||
|
||||
def new
|
||||
authorize :domain_allow, :create?
|
||||
end
|
||||
@ -23,9 +21,11 @@ module Admin
|
||||
authorize :domain_allow, :create?
|
||||
begin
|
||||
@import = Admin::Import.new(import_params)
|
||||
return render :new unless @import.validate
|
||||
|
||||
parse_import_data!(export_headers)
|
||||
|
||||
@data.take(ROWS_PROCESSING_LIMIT).each do |row|
|
||||
@data.take(Admin::Import::ROWS_PROCESSING_LIMIT).each do |row|
|
||||
domain = row['#domain'].strip
|
||||
next if DomainAllow.allowed?(domain)
|
||||
|
||||
|
@ -8,8 +8,6 @@ module Admin
|
||||
|
||||
before_action :set_dummy_import!, only: [:new]
|
||||
|
||||
ROWS_PROCESSING_LIMIT = 20_000
|
||||
|
||||
def new
|
||||
authorize :domain_block, :create?
|
||||
end
|
||||
@ -23,12 +21,14 @@ module Admin
|
||||
authorize :domain_block, :create?
|
||||
|
||||
@import = Admin::Import.new(import_params)
|
||||
return render :new unless @import.validate
|
||||
|
||||
parse_import_data!(export_headers)
|
||||
|
||||
@global_private_comment = I18n.t('admin.export_domain_blocks.import.private_comment_template', source: @import.data_file_name, date: I18n.l(Time.now.utc))
|
||||
|
||||
@form = Form::DomainBlockBatch.new
|
||||
@domain_blocks = @data.take(ROWS_PROCESSING_LIMIT).filter_map do |row|
|
||||
@domain_blocks = @data.take(Admin::Import::ROWS_PROCESSING_LIMIT).filter_map do |row|
|
||||
domain = row['#domain'].strip
|
||||
next if DomainBlock.rule_for(domain).present?
|
||||
|
||||
|
Reference in New Issue
Block a user