Sha256: 283290867c304b96642c918ed32acc9172564f2efac1087f29f9b8dce919d28a
Contents?: true
Size: 1.33 KB
Versions: 8
Compression:
Stored size: 1.33 KB
Contents
module Katello module Concerns module LocationExtensions extend ActiveSupport::Concern included do after_initialize :set_default_overrides, :if => :new_record? before_create :set_katello_default before_save :refute_katello_default_changed before_destroy :deletable? end def set_default_overrides self.ignore_types << ::ProvisioningTemplate.name self.ignore_types << ::Hostgroup.name end def set_katello_default if Location.default_location.nil? self.katello_default = true else self.katello_default = false end true end def deletable? if self.katello_default errors.add(:base, _("Cannot delete the default Location")) false end end def refute_katello_default_changed fail _("katello_default cannot be changed.") if Location.default_location && self.katello_default_changed? end module ClassMethods def default_location # In the future, we should have a better way to identify the 'default' location Location.where(:katello_default => true).first end def default_location_ids return [] unless default_location [default_location.id] end end end end end
Version data entries
8 entries across 8 versions & 1 rubygems