Revision acfbc458
Added by Marek Hulán about 10 years ago
app/controllers/hostgroups_controller.rb | ||
---|---|---|
class HostgroupsController < ApplicationController
|
||
include Foreman::Controller::HostDetails
|
||
include Foreman::Controller::AutoCompleteSearch
|
||
|
||
before_filter :find_hostgroup, :only => [:edit, :update, :destroy, :clone]
|
||
before_filter :find_by_name, :only => [:nest, :clone, :edit, :update, :destroy]
|
||
|
||
def index
|
||
@hostgroups = Hostgroup.my_groups.search_for(params[:search], :order => params[:order]).paginate(:page => params[:page])
|
||
@hostgroups = resource_base.search_for(params[:search], :order => params[:order]).paginate :page => params[:page]
|
||
end
|
||
|
||
def new
|
||
... | ... | |
end
|
||
|
||
def nest
|
||
@parent = Hostgroup.find(params[:id])
|
||
@parent = @hostgroup
|
||
@hostgroup = Hostgroup.new(:parent_id => @parent.id)
|
||
|
||
load_vars_for_ajax
|
||
... | ... | |
end
|
||
|
||
def edit
|
||
auth = User.current.admin? ? true : Hostgroup.my_groups.include?(@hostgroup)
|
||
not_found and return unless auth
|
||
load_vars_for_ajax
|
||
end
|
||
|
||
... | ... | |
|
||
def process_hostgroup
|
||
|
||
@parent = Hostgroup.find(params[:hostgroup][:parent_id]) if params[:hostgroup][:parent_id].to_i > 0
|
||
@parent = Hostgroup.authorized(:view_hostgroups).find(params[:hostgroup][:parent_id]) if params[:hostgroup][:parent_id].to_i > 0
|
||
return head(:not_found) unless @parent
|
||
|
||
@hostgroup = Hostgroup.new(params[:hostgroup])
|
||
... | ... | |
|
||
private
|
||
|
||
def find_hostgroup
|
||
@hostgroup = Hostgroup.find(params[:id])
|
||
end
|
||
|
||
def load_vars_for_ajax
|
||
return unless @hostgroup
|
||
@architecture = @hostgroup.architecture
|
||
... | ... | |
User.where(:subscribe_to_all_hostgroups => true)
|
||
end
|
||
|
||
def action_permission
|
||
case params[:action]
|
||
when 'nest', 'clone'
|
||
'view'
|
||
else
|
||
super
|
||
end
|
||
end
|
||
|
||
end
|
Also available in: Unified diff
fixes #812 - new permissions model, user group role and nest support, role filters for better granularity
Contributions from: