app/models/katello/pool.rb in katello-4.13.1 vs app/models/katello/pool.rb in katello-4.14.0.rc1
- old
+ new
@@ -53,10 +53,14 @@
validates :subscription, :presence => true
validates :organization, :presence => true
validate :subscription_matches_organization
+ def product_host_count
+ Katello::Host::ContentFacet.joins(bound_repositories: { product: :pools }).where(pools: { id: id }).distinct.count
+ end
+
def subscription_matches_organization
return if errors[:subscription].any? || errors[:organization].any? # let other validations catch this
unless subscription&.organization_id == self.organization_id
errors.add(:base, _("A Pool and its Subscription cannot belong to different organizations."))
end
@@ -145,10 +149,10 @@
property :start_date, ActiveSupport::TimeWithZone, desc: 'Returns subscription start date'
property :end_date, ActiveSupport::TimeWithZone, desc: 'Returns subscription end date'
property :days_until_expiration, Integer, desc: 'Returns number of days until expiration'
end
class Jail < ::Safemode::Jail
- allow :id, :name, :available, :quantity, :product_id, :contract_number, :type, :account_number, :start_date, :end_date, :organization, :consumed, :days_until_expiration
+ allow :id, :name, :available, :quantity, :product_id, :contract_number, :type, :account_number, :start_date, :end_date, :organization, :consumed, :days_until_expiration, :product_host_count
end
end
end
class ActiveRecord::AssociationRelation::Jail < Safemode::Jail