foreman/app/models/taxonomies/organization.rb @ be33e6e9
611f5bff | Amos Benari | class Organization < Taxonomy
|
|
8b737c9c | Joseph Magen | extend FriendlyId
|
|
friendly_id :title
|
|||
611f5bff | Amos Benari | include Foreman::ThreadSession::OrganizationModel
|
|
e768c976 | Tomas Strachota | include Parameterizable::ByIdName
|
|
611f5bff | Amos Benari | ||
has_and_belongs_to_many :locations
|
|||
3f77babd | Joseph Mitchell Magen | has_many_hosts :dependent => :nullify
|
|
7e1f0c79 | Daniel Lobato | ||
998e1438 | Ori Rabin | has_many :organization_parameters, :class_name => 'OrganizationParameter', :foreign_key => :reference_id, :dependent => :destroy, :inverse_of => :organization
|
|
7e1f0c79 | Daniel Lobato | has_many :default_users, :class_name => 'User', :foreign_key => :default_organization_id, :dependent => :nullify
|
|
32ced385 | Ori Rabin | accepts_nested_attributes_for :organization_parameters, :allow_destroy => true
|
|
998e1438 | Ori Rabin | include ParameterValidators
|
|
611f5bff | Amos Benari | ||
bb3572ff | Daniel Lobato | scope :completer_scope, ->(opts) { my_organizations }
|
|
611f5bff | Amos Benari | ||
scope :my_organizations, lambda {
|
|||
fb4e6a37 | Tom McKay | conditions = User.current.admin? ? {} : sanitize_sql_for_conditions([" (taxonomies.id in (?))", User.current.organization_and_child_ids])
|
|
96144a47 | Daniel Lobato | where(conditions)
|
|
}
|
|||
afa59582 | Ohad Levy | ||
feacea35 | Amos Benari | def dup
|
|
afa59582 | Ohad Levy | new = super
|
|
new.locations = locations
|
|||
new
|
|||
end
|
|||
1fa008a4 | Joseph Magen | ||
def lookup_value_match
|
|||
832c0925 | Joseph Magen | "organization=#{title}"
|
|
1fa008a4 | Joseph Magen | end
|
|
def sti_name
|
|||
_("organization")
|
|||
end
|
|||
611f5bff | Amos Benari | end
|