Skip to content

Commit

Permalink
make miq-bot happy: simplify and rename get_jobs method to 'list_jobs…
Browse files Browse the repository at this point in the history
…'and make it private
  • Loading branch information
yrudman committed Feb 10, 2017
1 parent ae9812b commit 7e305ae
Showing 1 changed file with 16 additions and 29 deletions.
45 changes: 16 additions & 29 deletions app/controllers/miq_task_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,19 @@ def build_jobs_tab
if role_allows?(:feature => "miq_task_all_ui")
@tabs.push(["4", _("All Other Tasks")])
end

@active_tab = @tabform.split("_").last
end

# Show job list for the current user
def jobs
build_jobs_tab
@title = _("Tasks for %{name}") % {:name => current_user.name}
@breadcrumbs = []
@lastaction = "jobs"

@edit = {}
@edit[:opts] = {}
@edit[:opts] = copy_hash(@tasks_options[@tabform]) # Backup current settings

get_jobs
list_jobs
if pagination_request?
render :update do |page|
page << javascript_prologue
Expand All @@ -72,30 +69,6 @@ def jobs
end
end

def get_jobs
@lastaction = "jobs"

if @tabform == "tasks_1"
@layout = "my_tasks"

elsif @tabform == "tasks_2"
# My UI Tasks
@layout = "my_ui_tasks"


elsif @tabform == "tasks_3" || @tabform == "alltasks_1"
@layout = "all_tasks"
@user_names = Job.distinct("userid").pluck("userid").delete_if(&:blank?)

elsif @tabform == "tasks_4" || @tabform == "alltasks_2"
# All UI Tasks
@layout = "all_ui_tasks"
@user_names = MiqTask.distinct("userid").pluck("userid").delete_if(&:blank?)
end

@view, @pages = get_view(db_class, :conditions => tasks_condition(@tasks_options[@tabform]))
end

# Cancel a single selected job
def canceljobs
assert_privileges("miq_task_canceljob")
Expand Down Expand Up @@ -281,7 +254,7 @@ def tasks_button
@edit[:opts] = copy_hash(@tasks_options[@tabform]) # Backup current settings
end

get_jobs # Get the jobs based on the latest options
list_jobs # Get the jobs based on the latest options
@pp_choices = PPCHOICES2 # Get special pp choices for jobs/tasks lists

render :update do |page|
Expand All @@ -300,6 +273,20 @@ def tasks_button

private ############################

def list_jobs
@lastaction = "jobs"
@active_tab = @tabform.split("_").last
case @tabform
when "tasks_1" then @layout = "my_tasks"
when "tasks_2" then @layout = "my_ui_tasks"
when "tasks_3", "alltasks_1" then @layout = "all_tasks"
when "tasks_4", "alltasks_2" then @layout = "all_ui_tasks"
end

@user_names = db_class.distinct("userid").pluck("userid").delete_if(&:blank?) if @active_tab.to_i > 2
@view, @pages = get_view(db_class, :conditions => tasks_condition(@tasks_options[@tabform]))
end

def db_class
case @tabform
when 'tasks_1', 'tasks_3' then Job
Expand Down

0 comments on commit 7e305ae

Please sign in to comment.