Class: Katello::Validators::ContentViewEnvironmentCoherentDefaultValidator
- Inherits:
-
ActiveModel::Validator
- Object
- ActiveModel::Validator
- Katello::Validators::ContentViewEnvironmentCoherentDefaultValidator
- Defined in:
- app/lib/katello/validators/content_view_environment_coherent_default_validator.rb
Overview
ensures that the Default Organization View content view can only be used with the Library environment
Instance Method Summary collapse
Instance Method Details
#validate(record) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'app/lib/katello/validators/content_view_environment_coherent_default_validator.rb', line 5 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 return if view.blank? || env.blank? if view.default? && !env.library? record.errors.add(:base, _("Lifecycle environment '%{env}' cannot be used with content view '%{view}'") % {:view => view.name, :env => env.name}) end end end end |