Sha256: 15f75cc7c99c7c5ddb96bd9a1d86da5311114d38721630df7b036e178305ed13

Contents?: true

Size: 1.13 KB

Versions: 32

Compression:

Stored size: 1.13 KB

Contents

module ForemanTasks
  class RecurringLogicsController < ::ApplicationController
    before_action :find_recurring_logic, :only => [:show, :cancel, :enable, :disable]

    def index
      @errors = params[:errors]
      @recurring_logics = filter(resource_base)
    end

    def show; end

    def enable
      change_enabled(true)
    end

    def disable
      change_enabled(false)
    end

    def cancel
      @recurring_logic.cancel
      redirect_to :action => :index
    end

    def controller_name
      'foreman_tasks_recurring_logics'
    end

    def resource_class
      ::ForemanTasks::RecurringLogic
    end

    private

    def change_enabled(value)
      begin
        @recurring_logic.update!(:enabled => value)
      rescue RecurringLogicCancelledException => e
        @errors = e.message
      end
      redirect_to :action => :index, :errors => @errors
    end

    def find_recurring_logic
      @recurring_logic ||= ::ForemanTasks::RecurringLogic.find(params[:id])
    end

    def filter(scope)
      scope.search_for(params[:search])
           .paginate(:page => params[:page], :per_page => params[:per_page])
    end
  end
end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
foreman-tasks-0.15.5 app/controllers/foreman_tasks/recurring_logics_controller.rb
foreman-tasks-0.15.4 app/controllers/foreman_tasks/recurring_logics_controller.rb
foreman-tasks-0.15.3 app/controllers/foreman_tasks/recurring_logics_controller.rb
foreman-tasks-0.15.2 app/controllers/foreman_tasks/recurring_logics_controller.rb
foreman-tasks-0.15.1 app/controllers/foreman_tasks/recurring_logics_controller.rb
foreman-tasks-0.15.0 app/controllers/foreman_tasks/recurring_logics_controller.rb
foreman-tasks-0.14.5 app/controllers/foreman_tasks/recurring_logics_controller.rb
foreman-tasks-0.14.4 app/controllers/foreman_tasks/recurring_logics_controller.rb
foreman-tasks-0.14.3 app/controllers/foreman_tasks/recurring_logics_controller.rb
foreman-tasks-0.14.2 app/controllers/foreman_tasks/recurring_logics_controller.rb
foreman-tasks-0.14.1 app/controllers/foreman_tasks/recurring_logics_controller.rb
foreman-tasks-0.14.0 app/controllers/foreman_tasks/recurring_logics_controller.rb