Sha256: b994f1f32a18a394e2ab07b873825f281a685b3b8e72d92eaad2d1e91f5b77a0

Contents?: true

Size: 1.09 KB

Versions: 9

Compression:

Stored size: 1.09 KB

Contents

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

    ISSUED = "issued"
    UPDATED = "updated"
    DATE_TYPES = [ISSUED, UPDATED]

    belongs_to :filter,
               :class_name => "Katello::ContentViewErratumFilter",
               :inverse_of => :erratum_rules,
               :foreign_key => :content_view_filter_id

    serialize :types, Array

    validates_lengths_from_database
    validates :errata_id, :uniqueness => { :scope => :content_view_filter_id }, :allow_blank => true
    validates_with Validators::ContentViewErratumFilterRuleValidator

    validates :date_type,
      :if => proc { |o| o.start_date || o.end_date },
      :inclusion => {
        :in => DATE_TYPES,
        :allow_blank => false,
        :message => (_("must be one of the following: %s") % DATE_TYPES.join(', '))
      }

    def filter_has_date_or_type_rule?
      filter.erratum_rules.any? { |rule| rule.start_date || rule.end_date || !rule.types.blank? }
    end

    def pulp_date_type
      self.date_type == ISSUED ? "issued" : "updated"
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
katello-3.0.2 app/models/katello/content_view_erratum_filter_rule.rb
katello-3.0.1 app/models/katello/content_view_erratum_filter_rule.rb
katello-3.0.0 app/models/katello/content_view_erratum_filter_rule.rb
katello-3.0.0.rc7 app/models/katello/content_view_erratum_filter_rule.rb
katello-3.0.0.rc5 app/models/katello/content_view_erratum_filter_rule.rb
katello-3.0.0.rc4 app/models/katello/content_view_erratum_filter_rule.rb
katello-3.0.0.rc3 app/models/katello/content_view_erratum_filter_rule.rb
katello-3.0.0.rc2 app/models/katello/content_view_erratum_filter_rule.rb
katello-3.0.0.rc1 app/models/katello/content_view_erratum_filter_rule.rb