Sha256: f881fcc8c4f9fc0d90ce823a3db6c054e455e7da47b5506cdec7b825d98a667b

Contents?: true

Size: 1.87 KB

Versions: 59

Compression:

Stored size: 1.87 KB

Contents

module Katello
  class ContentViewPuppetModule < Katello::Model
    audited :associated_with => :content_view
    belongs_to :content_view, :class_name => "Katello::ContentView", :inverse_of => :content_view_versions

    validates_lengths_from_database
    validates :content_view_id, :presence => true
    validates :name, :uniqueness => { :scope => :content_view_id, :message => _('There is already a module named "%{value}" in this content view.') }
    validates :uuid, :uniqueness => { :scope => :content_view_id }, :allow_blank => true

    validates_with Validators::ContentViewPuppetModuleValidator

    scoped_search :on => :name, :complete_value => true
    scoped_search :on => :author, :complete_value => true
    scoped_search :on => :uuid, :complete_value => true
    scoped_search :on => :name, :relation => :content_view, :rename => :content_view_name

    before_validation :set_attributes

    def puppet_module
      PuppetModule.find_by(:pulp_id => self.uuid)
    end

    def computed_version
      if self.uuid
        puppet_module = PuppetModule.where(:pulp_id => self.uuid).first
      else
        puppet_module = PuppetModule.latest_module(
          self.name,
          self.author,
          self.content_view.puppet_repos
        )
      end

      puppet_module.try(:version)
    end

    def latest_in_modules_by_author?(puppet_module_list)
      latest_from_list = puppet_module_list.where(:author => self.author).order(:sortable_version => :desc).first
      self.computed_version.eql?(latest_from_list.try(:version))
    end

    private

    def set_attributes
      if self.uuid.present?
        puppet_module = PuppetModule.with_identifiers(self.uuid).first
        fail Errors::NotFound, _("Couldn't find Puppet Module with id '%s'") % self.uuid unless puppet_module

        self.name = puppet_module.name
        self.author = puppet_module.author
      end
    end
  end
end

Version data entries

59 entries across 59 versions & 1 rubygems

Version Path
katello-3.17.3 app/models/katello/content_view_puppet_module.rb
katello-3.17.2 app/models/katello/content_view_puppet_module.rb
katello-3.17.1 app/models/katello/content_view_puppet_module.rb
katello-3.16.2 app/models/katello/content_view_puppet_module.rb
katello-3.17.0 app/models/katello/content_view_puppet_module.rb
katello-3.18.0.rc1 app/models/katello/content_view_puppet_module.rb
katello-3.17.0.rc2.2 app/models/katello/content_view_puppet_module.rb
katello-3.17.0.rc2.1 app/models/katello/content_view_puppet_module.rb
katello-3.16.1.2 app/models/katello/content_view_puppet_module.rb
katello-3.16.1.1 app/models/katello/content_view_puppet_module.rb
katello-3.17.0.rc2 app/models/katello/content_view_puppet_module.rb
katello-3.16.1 app/models/katello/content_view_puppet_module.rb
katello-3.17.0.rc1 app/models/katello/content_view_puppet_module.rb
katello-3.16.0 app/models/katello/content_view_puppet_module.rb
katello-3.16.0.rc5.1 app/models/katello/content_view_puppet_module.rb
katello-3.16.0.rc5 app/models/katello/content_view_puppet_module.rb
katello-3.16.0.rc4.1 app/models/katello/content_view_puppet_module.rb
katello-3.15.3.1 app/models/katello/content_view_puppet_module.rb
katello-3.15.3 app/models/katello/content_view_puppet_module.rb
katello-3.16.0.rc4 app/models/katello/content_view_puppet_module.rb