Project

General

Profile

« Previous | Next » 

Revision ffbb8214

Added by Amos Benari over 11 years ago

  • ID ffbb82142c0c561f6afb495198a70eddd4a1afa1

scope templates by taxonomy.

View differences:

app/models/config_template.rb
class ConfigTemplate < ActiveRecord::Base
include Authorization
include Taxonomix
audited
self.auditing_enabled = !defined?(Rake)
attr_accessible :name, :template, :template_kind_id, :snippet, :template_combinations_attributes, :operatingsystem_ids, :audit_comment
......
has_many :os_default_templates
before_save :check_for_snippet_assoications, :remove_trailing_chars
before_destroy EnsureNotUsedBy.new(:hostgroups, :environments, :os_default_templates)
default_scope :order => 'LOWER(config_templates.name)'
# with proc support, default_scope can no longer be chained
# include all default scoping here
default_scope lambda {
with_taxonomy_scope do
order("LOWER(config_templates.name)")
end
}
scoped_search :on => :name, :complete_value => true, :default_order => true
scoped_search :on => :snippet, :complete_value => true, :complete_value => {:true => true, :false => false}
app/models/taxonomy.rb
has_many :smart_proxies, :through => :taxable_taxonomies, :source => :taxable, :source_type => 'SmartProxy'
has_many :compute_resources, :through => :taxable_taxonomies, :source => :taxable, :source_type => 'ComputeResource'
has_many :media, :through => :taxable_taxonomies, :source => :taxable, :source_type => 'Medium'
has_many :config_templates, :through => :taxable_taxonomies, :source => :taxable, :source_type => 'ConfigTemplate'
has_many :domains, :through => :taxable_taxonomies, :source => :taxable, :source_type => 'Domain'
has_many :hostgroups, :through => :taxable_taxonomies, :source => :taxable, :source_type => 'Hostgroup'
has_many :environments, :through => :taxable_taxonomies, :source => :taxable, :source_type => 'Environment'
app/views/taxonomy/_form.html.erb
<li><a href="#subnets" data-toggle="tab">Subnets</a></li>
<li><a href="#compute_resources" data-toggle="tab">Compute Resources</a></li>
<li><a href="#media" data-toggle="tab">Media</a></li>
<li><a href="#template" data-toggle="tab">Provisioning Template</a></li>
<li><a href="#domains" data-toggle="tab">Domains</a></li>
<li><a href="#environments" data-toggle="tab">Environments</a></li>
<li><a href="#hostgroups" data-toggle="tab">Host Groups</a></li>
......
<%= multiple_checkboxes f, :media, taxonomy, Medium %>
</div>
<div class="tab-pane" id="template">
<%= multiple_checkboxes f, :config_templates, taxonomy, ConfigTemplate %>
</div>
<div class="tab-pane" id="domains">
<%= multiple_checkboxes f, :domains, taxonomy, Domain %>
</div>

Also available in: Unified diff