Sha256: 2e85fadc9fff3b276e597ab360ceb5a02071c6af2af8fdcabc865c01ada9fc0d

Contents?: true

Size: 650 Bytes

Versions: 202

Compression:

Stored size: 650 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
        if label.blank?
          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

202 entries across 202 versions & 1 rubygems

Version Path
katello-4.11.0.rc2 app/models/katello/ext/label_from_name.rb
katello-4.11.0.rc1 app/models/katello/ext/label_from_name.rb
katello-4.10.0 app/models/katello/ext/label_from_name.rb
katello-4.9.2 app/models/katello/ext/label_from_name.rb
katello-4.10.0.rc2 app/models/katello/ext/label_from_name.rb
katello-4.10.0.rc1 app/models/katello/ext/label_from_name.rb
katello-4.8.4 app/models/katello/ext/label_from_name.rb
katello-4.9.1 app/models/katello/ext/label_from_name.rb
katello-4.8.3 app/models/katello/ext/label_from_name.rb
katello-4.9.0 app/models/katello/ext/label_from_name.rb
katello-4.7.6 app/models/katello/ext/label_from_name.rb
katello-4.8.2 app/models/katello/ext/label_from_name.rb
katello-4.9.0.rc2 app/models/katello/ext/label_from_name.rb
katello-4.9.0.rc1 app/models/katello/ext/label_from_name.rb
katello-4.8.1 app/models/katello/ext/label_from_name.rb
katello-4.7.5 app/models/katello/ext/label_from_name.rb
katello-4.8.0 app/models/katello/ext/label_from_name.rb
katello-4.8.0.rc2 app/models/katello/ext/label_from_name.rb
katello-4.7.4 app/models/katello/ext/label_from_name.rb
katello-4.8.0.rc1 app/models/katello/ext/label_from_name.rb