Sha256: a8ac3e1b78252daf75b679d538f58ccdf20dafce52bc3a4d5d4402889e691a16

Contents?: true

Size: 1.61 KB

Versions: 11

Compression:

Stored size: 1.61 KB

Contents

module Katello
  class GpgKey < Katello::Model
    self.include_root_in_json = false

    include Katello::Authorization::GpgKey
    MAX_CONTENT_LENGTH = 100_000
    MAX_CONTENT_LINE_LENGTH = 65

    has_many :repositories, :class_name => "Katello::Repository", :inverse_of => :gpg_key, :dependent => :nullify
    has_many :products, :class_name => "Katello::Product", :inverse_of => :gpg_key, :dependent => :nullify

    belongs_to :organization, :inverse_of => :gpg_keys

    validates_lengths_from_database
    validates :name, :presence => true, :uniqueness => {:scope => :organization_id,
                                                        :message => N_("has already been taken")}
    validates :content, :presence => true, :length => {:maximum => MAX_CONTENT_LENGTH}
    validates :organization, :presence => true
    validates_with Validators::KatelloNameFormatValidator, :attributes => :name
    validates_with Validators::ContentValidator, :attributes => :content
    validates_with Validators::GpgKeyContentValidator, :attributes => :content, :if => proc { SETTINGS[:katello][:gpg_strict_validation] }

    scoped_search :on => :name, :complete_value => true
    scoped_search :on => :organization_id, :complete_value => true

    def as_json(options = {})
      options ||= {}
      ret = super(options.except(:details))
      if options[:details]
        ret[:products] = products.map { |p| {:name => p.name} }
        ret[:repositories] = repositories.map { |r| {:product => {:name => r.product.name}, :name => r.name} }
      end
      ret
    end

    def self.humanize_class_name(_name = nil)
      _("GPG Keys")
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
katello-2.4.5 app/models/katello/gpg_key.rb
katello-2.4.4 app/models/katello/gpg_key.rb
katello-2.4.3 app/models/katello/gpg_key.rb
katello-2.4.2 app/models/katello/gpg_key.rb
katello-3.0.0.rc2 app/models/katello/gpg_key.rb
katello-3.0.0.rc1 app/models/katello/gpg_key.rb
katello-2.4.1 app/models/katello/gpg_key.rb
katello-2.4.0 app/models/katello/gpg_key.rb
katello-2.4.0.rc3 app/models/katello/gpg_key.rb
katello-2.4.0.rc2 app/models/katello/gpg_key.rb
katello-2.4.0.rc1 app/models/katello/gpg_key.rb