Sha256: 52c880a42a354e2d410cd2d2c05d8afdc774400ea8c23d599d5f5949633db352
Contents?: true
Size: 1.58 KB
Versions: 3
Compression:
Stored size: 1.58 KB
Contents
module Katello class ContentViewErratumFilterRule < Katello::Model include ::Katello::Concerns::ContentViewFilterRuleCommon before_create :default_types ISSUED = "issued".freeze UPDATED = "updated".freeze DATE_TYPES = [ISSUED, UPDATED].freeze belongs_to :filter, :class_name => "Katello::ContentViewErratumFilter", :inverse_of => :erratum_rules, :foreign_key => :content_view_filter_id serialize :types, Array 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 self.in_content_views(content_view_ids) joins('INNER JOIN katello_content_view_filters ON katello_content_view_erratum_filter_rules.content_view_filter_id = katello_content_view_filters.id'). where("katello_content_view_filters.content_view_id IN (#{content_view_ids.join(',')})") end 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 def default_types if errata_id.nil? && types.blank? self.types = ContentViewErratumFilter::ERRATA_TYPES.keys end end end end
Version data entries
3 entries across 3 versions & 1 rubygems