Project

General

Profile

Download (886 Bytes) Statistics
| Branch: | Tag: | Revision:

foreman_pipeline / app / controllers / foreman_pipeline / api / paths_controller.rb @ abf1341e

1
module ForemanPipeline
2
  class Api::PathsController < Katello::Api::V2::ApiController
3
    respond_to :json
4

    
5
    include Api::Rendering
6

    
7
    before_filter :find_organization, :only => [:all_paths]
8

    
9
    def all_paths
10
      env_paths = if params[:permission_type] == "promotable"
11
                    @organization.promotable_promotion_paths
12
                  else
13
                    @organization.readable_promotion_paths
14
                  end
15

    
16
      paths = env_paths.inject([]) do |result, path|
17
        result << { :environments => [@organization.library] + path }
18
      end
19
      paths = [{ :environments => [@organization.library] }] if paths.empty?
20

    
21
      collection = {
22
        :results => paths,
23
        :total => paths.size,
24
        :subtotal => paths.size
25
      }
26
      respond_for_index(:collection => collection, :template => '../jobs/available_paths')
27
    end 
28
    
29
  end
30
end