Project

General

Profile

Download (626 Bytes) Statistics
| Branch: | Tag: | Revision:
086ec942 Ohad Levy
class GroupParameter < Parameter
aa1796f3 Paul Kelly
belongs_to :hostgroup, :foreign_key => :reference_id
validates_uniqueness_of :name, :scope => :reference_id
9fd7478e Paul Kelly
private
def enforce_permissions operation
# We get called again with the operation being set to create
return true if operation == "edit" and new_record?

current = User.current

if current.allowed_to?("#{operation}_hostgroups".to_sym)
if current.hostgroups.empty? or current.hostgroups.include? hostgroup
return true
end
end

errors.add_to_base "You do not have permission to #{operation} this group parameter"
false
end
086ec942 Ohad Levy
end