-
Notifications
You must be signed in to change notification settings - Fork 45
Expand file tree
/
Copy pathbulk_url_upload_controller.rb
More file actions
42 lines (35 loc) · 1.01 KB
/
bulk_url_upload_controller.rb
File metadata and controls
42 lines (35 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# frozen_string_literal: true
module Admin
class BulkUrlUploadController < AdminController
include BulkUploadHandler
before_action :set_page_title
def index; end
def upload
handle_bulk_upload(
params_key: :bulk_upload_urls,
validator_class: BulkUrlUploader::UrlFileValidator,
error_class: BulkUrlUploader::Error,
success_path: admin_bulk_url_upload_index_path,
logger_message: 'Url upload failed'
)
end
private
def set_page_title
@page_title = 'Bulk URL Upload'
end
def success_message(filename)
<<~SUCCESS_MESSAGE
Successfully uploaded #{filename} for processing.
The results will be emailed to you.
SUCCESS_MESSAGE
end
def enqueue_job
SearchgovUrlBulkUploaderJob.perform_later(
current_user,
@file.original_filename,
@file.tempfile.set_encoding('UTF-8').readlines,
reindex: ActiveModel::Type::Boolean.new.cast(params[:reindex])
)
end
end
end