Class: Katello::Validators::ContentViewEnvironmentValidator
- Inherits:
-
ActiveModel::Validator
- Object
- ActiveModel::Validator
- Katello::Validators::ContentViewEnvironmentValidator
- Defined in:
- app/lib/katello/validators/content_view_environment_validator.rb
Overview
used by activation key and content facet
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 20 21 |
# File 'app/lib/katello/validators/content_view_environment_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 unless view.blank? || env.blank? || view.in_environment?(env) record.errors.add(:base, _("Content view '%{view}' is not in environment '%{env}'") % {:view => view.name, :env => env.name}) end end if view&.generated_for_repository? record.errors.add(:base, _("Generated content views cannot be assigned to hosts or activation keys")) end end end |