Class: CommandProposal::TasksController
Instance Method Summary
collapse
#approval_required?, #can_approve?, #can_command?, #cmd_config, #command_user, #current_is_author?, #has_approval?, #permitted_to_use?
#command_paginate, #current_params, #current_path, #div, #humanized_duration, #sort_order, #toggled_param, #toggled_sort_order, #true_param?, #truthy?
#cmd_path, #cmd_url, #engine, #runner_path, #runner_url, #string_path
Instance Method Details
#create ⇒ Object
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
# File 'app/controllers/command_proposal/tasks_controller.rb', line 53
def create
@task = ::CommandProposal::Task.new(task_params.except(:code))
@task.user = command_user
@task.skip_approval = true unless approval_required?(@task.session_type)
if @task.save && @task.update(task_params)
if @task.console?
@task.code = nil redirect_to cmd_path(@task)
else
redirect_to cmd_path(:edit, @task)
end
else
render "form"
end
end
|
#edit ⇒ Object
47
48
49
50
51
|
# File 'app/controllers/command_proposal/tasks_controller.rb', line 47
def edit
@task = ::CommandProposal::Task.find_by!(friendly_id: params[:id])
render "form"
end
|
#index ⇒ Object
16
17
18
19
20
21
22
|
# File 'app/controllers/command_proposal/tasks_controller.rb', line 16
def index
@tasks = ::CommandProposal::Task.includes(:iterations)
@tasks = @tasks.order(Arel.sql("COALESCE(command_proposal_tasks.last_executed_at, command_proposal_tasks.created_at) DESC"))
@tasks = @tasks.search(params[:search]) if params[:search].present?
@tasks = @tasks.by_session(params[:filter])
@tasks = @tasks.cmd_page(params[:page])
end
|
#new ⇒ Object
40
41
42
43
44
45
|
# File 'app/controllers/command_proposal/tasks_controller.rb', line 40
def new
@task = ::CommandProposal::Task.new
@task.session_type = params[:session_type] if params[:session_type].in?(::CommandProposal::Task.session_types)
render "form"
end
|
#search ⇒ Object
12
13
14
|
# File 'app/controllers/command_proposal/tasks_controller.rb', line 12
def search
redirect_to cmd_path(:tasks, current_params)
end
|
#show ⇒ Object
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'app/controllers/command_proposal/tasks_controller.rb', line 24
def show
@task = ::CommandProposal::Task.find_by!(friendly_id: params[:id])
if @task.console?
@lines = @task.lines
@iteration = @task.first_iteration
return end
if params.key?(:iteration)
@iteration = @task.iterations.find(params[:iteration])
else
@iteration = @task.current_iteration
end
end
|
#update ⇒ Object
72
73
74
75
76
77
78
79
80
81
82
83
|
# File 'app/controllers/command_proposal/tasks_controller.rb', line 72
def update
@task = ::CommandProposal::Task.find_by!(friendly_id: params[:id])
@task.user = command_user
@task.skip_approval = true unless approval_required?(@task.session_type)
if @task.update(task_params)
redirect_to cmd_path(@task)
else
render "form"
end
end
|