Skip to content

Commit

Permalink
Add XML API endpoint to list all staging_projects
Browse files Browse the repository at this point in the history
Endpoint to XML API to list all staging_projects within a staging
workflow
  • Loading branch information
vpereira committed Nov 22, 2018
1 parent e332917 commit d2c2376
Show file tree
Hide file tree
Showing 36 changed files with 6,033 additions and 5,934 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ def destroy
private

def set_staging_workflow
project = Project.get_by_name(params[:project_name])
project = Project.get_by_name(params[:staging_main_project_name])
@staging_workflow = project.staging
return if @staging_workflow

raise InvalidParameterError, "Project #{params[:project_name]} doesn't have an asociated Staging Workflow"
raise InvalidParameterError, "Project #{params[:staging_main_project_name]} doesn't have an asociated Staging Workflow"
end

def set_request_exclusion
Expand Down
19 changes: 18 additions & 1 deletion src/api/app/controllers/staging/staging_projects_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,24 @@
class Staging::StagingProjectsController < ApplicationController
skip_before_action :require_login

before_action :set_main_project

def index
if @main_project.staging
@staging_workflow = @main_project.staging
@staging_projects = @staging_workflow.staging_projects
else
render_error status: 400, errcode: 'project_has_no_staging_workflow'
end
end

def show
@staging_project = Staging::StagingProject.get_by_name(params[:name])
@staging_project = @main_project.staging.staging_projects.find_by!(name: params[:name])
end

private

def set_main_project
@main_project = Project.find_by!(name: params[:staging_main_project_name])
end
end
23 changes: 23 additions & 0 deletions src/api/app/views/staging/staging_projects/index.xml.builder
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
xml.staging_projects do
@staging_projects.each do |staging_project|
xml.staging_project(name: staging_project.name) do
render(partial: 'staging/staging_projects/staged_requests', locals: { staged_requests: staging_project.staged_requests,
count: staging_project.staged_requests.count, builder: xml })

render(partial: 'staging/staging_projects/untracked_requests', locals: { untracked_requests: staging_project.untracked_requests,
count: staging_project.untracked_requests.count, builder: xml })

render(partial: 'staging/staging_projects/requests_to_review', locals: { requests_to_review: staging_project.requests_to_review,
count: staging_project.requests_to_review.count, builder: xml })

render(partial: 'staging/staging_projects/missing_reviews', locals: { missing_reviews: staging_project.missing_reviews,
count: staging_project.missing_reviews.count, builder: xml })

render(partial: 'staging/staging_projects/building_repositories', locals: { building_repositories: staging_project.building_repositories,
count: staging_project.building_repositories.count, builder: xml })

render(partial: 'staging/staging_projects/broken_packages', locals: { broken_packages: staging_project.broken_packages,
count: staging_project.broken_packages.count, builder: xml })
end
end
end
16 changes: 9 additions & 7 deletions src/api/config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -731,15 +731,17 @@ def self.public_or_about_path?(request)
end

# StagingWorkflow API
scope module: 'staging' do
resources :staging_projects, only: [:show], param: :name do
get 'staged_requests' => 'staged_requests#index', constraints: cons
resource :staged_requests, controller: 'staged_requests', only: [:create, :destroy], constraints: cons
resources :staging, only: [], param: 'main_project_name' do
resources :staging_projects, only: [:index, :show], controller: 'staging/staging_projects', param: :name do
get 'staged_requests' => 'staging/staged_requests#index', constraints: cons
resource :staged_requests, controller: 'staging/staged_requests', only: [:create, :destroy], constraints: cons
end

controller 'excluded_requests' do
post 'staging_excluded_requests/:number/:project_name' => :create, constraints: cons
delete 'staging_excluded_requests/:number' => :destroy, constraints: cons
# resources :excluded_requests, only: [:create, :destroy], controller: 'staging/excluded_requests', param: :number, constrains: cons

controller 'staging/excluded_requests' do
post 'excluded_requests/:number' => :create, constraints: cons
delete 'excluded_requests/:number' => :destroy, constraints: cons
end
end

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d2c2376

Please sign in to comment.