Sha256: a48ab0e0e8c2f7e707ec091891427111f0ab180496fbe4e6ce1ca6b365602ffa

Contents?: true

Size: 656 Bytes

Versions: 37

Compression:

Stored size: 656 Bytes

Contents

module Katello
  module Ext
    module LabelFromName
      def self.included(base)
        base.class_eval do
          before_validation :setup_label_from_name
          validate :label_not_changed, :on => :update
        end
      end

      def setup_label_from_name
        unless label.present?
          self.label = Util::Model.labelize(name)
          if self.class.where(:label => self.label).any?
            self.label = Util::Model.uuid
          end
        end
      end

      def label_not_changed
        if label_changed? && label_was.present?
          errors.add(:label, _("cannot be changed."))
        end
      end
    end
  end
end

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
katello-3.4.5 app/models/katello/ext/label_from_name.rb
katello-3.4.4 app/models/katello/ext/label_from_name.rb
katello-3.4.2 app/models/katello/ext/label_from_name.rb
katello-3.4.1 app/models/katello/ext/label_from_name.rb
katello-3.4.0.2 app/models/katello/ext/label_from_name.rb
katello-3.4.0.1 app/models/katello/ext/label_from_name.rb
katello-3.3.2 app/models/katello/ext/label_from_name.rb
katello-3.4.0 app/models/katello/ext/label_from_name.rb
katello-3.4.0.rc2 app/models/katello/ext/label_from_name.rb
katello-3.4.0.rc1 app/models/katello/ext/label_from_name.rb
katello-3.3.1.1 app/models/katello/ext/label_from_name.rb
katello-3.3.1 app/models/katello/ext/label_from_name.rb
katello-3.3.0.1 app/models/katello/ext/label_from_name.rb
katello-3.3.0 app/models/katello/ext/label_from_name.rb
katello-3.3.0.rc2 app/models/katello/ext/label_from_name.rb
katello-3.3.0.rc1.1 app/models/katello/ext/label_from_name.rb
katello-3.3.0.rc1 app/models/katello/ext/label_from_name.rb
katello-3.2.1.1 app/models/katello/ext/label_from_name.rb
katello-3.2.1 app/models/katello/ext/label_from_name.rb
katello-3.2.0 app/models/katello/ext/label_from_name.rb