Sha256: 014105a6d58767df433736130541fc5a0e1dfec82b024a4cfff8a2e1b546b993
Contents?: true
Size: 1.81 KB
Versions: 4
Compression:
Stored size: 1.81 KB
Contents
class DiscoveryRulesController < ApplicationController # Two-pane searching must be disabled for rules otherwise query completion will not work #include Foreman::Controller::AutoCompleteSearch include Foreman::Controller::Parameters::DiscoveryRule before_action :find_resource, :only => [:edit, :update, :destroy, :enable, :disable, :auto_provision, :clone] def model_of_controller DiscoveryRule end def index base = resource_base.search_for(params[:search], :order => (params[:order])) @discovery_rules = base.paginate(:page => params[:page], :per_page => params[:per_page]).includes(:hostgroup) end def new @discovery_rule = DiscoveryRule.new(:priority => DiscoveryRule.suggest_priority) end def clone @discovery_rule.deep_clone except: [:name, :priority], include: [:organizations, :locations] @discovery_rule.priority = DiscoveryRule.suggest_priority end def create @discovery_rule = DiscoveryRule.new(discovery_rule_params) if @discovery_rule.save process_success else process_error end end def edit end def update if @discovery_rule.update(discovery_rule_params) process_success else process_error end end def destroy if @discovery_rule.destroy process_success else process_error end end def enable set_enabled true end def disable set_enabled false end private def action_permission case params[:action] when 'clone' :create when 'enable', 'disable' :edit else super end end def set_enabled(enabled) @discovery_rule.enabled = enabled if @discovery_rule.save process_success :success_msg => (enabled ? _('Rule enabled') : _('Rule disabled')), :success_redirect => :back else process_error end end end
Version data entries
4 entries across 4 versions & 1 rubygems