Sha256: 457b9885c78b4279f05a0d194fd99c2a19fb89128e7903e921702b5e027b9545
Contents?: true
Size: 1013 Bytes
Versions: 15
Compression:
Stored size: 1013 Bytes
Contents
module Katello module Validators class ContentViewEnvironmentValidator < ActiveModel::Validator def validate(record) #support lifecycle_environment_id for foreman models environment_id = record.respond_to?(:lifecycle_environment_id) ? record.lifecycle_environment_id : record.environment_id if record.content_view_id view = ContentView.where(:id => record.content_view_id).first if environment_id env = KTEnvironment.where(:id => environment_id).first unless view.blank? || env.blank? || view.in_environment?(env) record.errors[:base] << _("Content view '%{view}' is not in environment '%{env}'") % {:view => view.name, :env => env.name} end end if view&.generated_for_repository? record.errors[:base] << _("Generated content views cannot be assigned to hosts or activation keys") end end end end end end
Version data entries
15 entries across 15 versions & 1 rubygems