Sha256: 9e986923a8ecd766cdd21f0e0ea6afd2b43002a3fb2ce950a5503e3ed15d9a17

Contents?: true

Size: 928 Bytes

Versions: 4

Compression:

Stored size: 928 Bytes

Contents

module Katello
  module Validators
    class ContentViewEnvironmentOrgValidator < ActiveModel::Validator
      def validate(record)
        environment_id = record.respond_to?(:lifecycle_environment_id) ? record.lifecycle_environment_id : record.environment_id
        view = ContentView.where(:id => record.content_view_id).first
        environment = KTEnvironment.where(:id => environment_id).first
        if view.blank? || environment.blank?
          record.errors[:base] << _("Content view environments must have both a content view and an environment")
        end

        unless view&.organization == environment&.organization
          record.errors[:base] << _("%{view_label} could not be promoted to %{environment_label} because the content view and the environment are not in the same organization!") % {:view_label => view&.label, :environment_label => environment&.label}
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
katello-4.15.1 app/lib/katello/validators/content_view_environment_org_validator.rb
katello-4.15.0 app/lib/katello/validators/content_view_environment_org_validator.rb
katello-4.15.0.rc2 app/lib/katello/validators/content_view_environment_org_validator.rb
katello-4.15.0.rc1 app/lib/katello/validators/content_view_environment_org_validator.rb