1class Admin::TasksController < Admin::AdminController |
|
2 before_action :require_sysadmin |
|
3 before_action :redirect_to_tasks_tab, if: :missing_tasks? |
|
5 def create |
|
6 if Admin::TaskRunner.run(params) |
|
7 notice = [:started_tasks, count: selected_tasks.size] |
|
8 else |
|
9 notice = [:failed_tasks] |
|
10 end |
|
12 redirect_to edit_admin_site_path(tab: "tasks"), notice: notice |
|
13 end |
|
15 private
|
|
17 def redirect_to_tasks_tab |
|
18 redirect_to edit_admin_site_path(tab: "tasks"), notice: :missing_tasks |
|
19 end |
|
21 def missing_tasks? |
|
22 selected_tasks.empty?
|
|
23 end |
|
25 def selected_tasks |
|
26 Array(params[:tasks]) |
|
27 end |
|
28end |