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.14.2 app/models/katello/ext/label_from_name.rb
katello-4.15.0 app/models/katello/ext/label_from_name.rb
katello-4.15.0.rc2 app/models/katello/ext/label_from_name.rb
katello-4.15.0.rc1 app/models/katello/ext/label_from_name.rb
katello-4.14.1 app/models/katello/ext/label_from_name.rb
katello-4.14.0 app/models/katello/ext/label_from_name.rb
katello-4.14.0.rc3 app/models/katello/ext/label_from_name.rb
katello-4.14.0.rc2 app/models/katello/ext/label_from_name.rb
katello-4.14.0.rc1.1 app/models/katello/ext/label_from_name.rb
katello-4.14.0.rc1 app/models/katello/ext/label_from_name.rb
katello-4.13.1 app/models/katello/ext/label_from_name.rb
katello-4.13.0 app/models/katello/ext/label_from_name.rb
katello-4.12.1 app/models/katello/ext/label_from_name.rb
katello-4.13.0.rc1 app/models/katello/ext/label_from_name.rb
katello-4.12.0 app/models/katello/ext/label_from_name.rb
katello-4.12.0.rc3 app/models/katello/ext/label_from_name.rb
katello-4.12.0.rc2 app/models/katello/ext/label_from_name.rb
katello-4.12.0.rc1 app/models/katello/ext/label_from_name.rb
katello-4.11.1 app/models/katello/ext/label_from_name.rb
katello-4.11.0 app/models/katello/ext/label_from_name.rb