#686: added API for show list of projects
This commit is contained in:
parent
3413a681af
commit
351821912b
|
@ -6,6 +6,11 @@ class Api::V1::ProjectsController < Api::V1::BaseController
|
|||
|
||||
load_and_authorize_resource
|
||||
|
||||
def index
|
||||
@projects = Project.accessible_by(current_ability, :membered).
|
||||
paginate(paginate_params)
|
||||
end
|
||||
|
||||
def get_id
|
||||
if @project = Project.find_by_owner_and_name(params[:owner], params[:name])
|
||||
authorize! :show, @project
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
json.projects @projects do |json, project|
|
||||
json.(project, :id, :name, :visibility)
|
||||
json.(project, :id, :name, :visibility, :description, :ancestry, :has_issues, :has_wiki, :default_branch, :is_package, :average_build_time)
|
||||
json.created_at project.created_at.to_i
|
||||
json.updated_at project.updated_at.to_i
|
||||
json.owner do |json_owner|
|
||||
json_owner.(project.owner, :id, :name)
|
||||
json_owner.type project.owner_type
|
||||
json_owner.url url_for(project.owner)
|
||||
json_owner.url member_path(project.owner)
|
||||
end
|
||||
json.url api_v1_project_path(project, :format => :json)
|
||||
json.url api_v1_project_path(project.id, :format => :json)
|
||||
end
|
||||
|
||||
json.url api_v1_projects_path(:format => :json)
|
|
@ -1,12 +1,16 @@
|
|||
json.project do |json|
|
||||
json.(@project, :id, :name, :visibility, :description, :ancestry, :has_issues, :has_wiki,
|
||||
:default_branch, :is_package, :average_build_time)
|
||||
json.(@project, :id, :name, :visibility, :description, :ancestry, :has_issues, :has_wiki, :default_branch, :is_package, :average_build_time)
|
||||
json.created_at @project.created_at.to_i
|
||||
json.updated_at @project.updated_at.to_i
|
||||
json.owner do |json_owner|
|
||||
json_owner.(@project.owner, :id, :name)
|
||||
json_owner.type @project.owner_type
|
||||
json_owner.url url_for(@project.owner)
|
||||
json_owner.url member_path(@project.owner)
|
||||
end
|
||||
json.maintainer do |json_maintainer|
|
||||
json_maintainer.(@project.maintainer, :id, :name)
|
||||
json_maintainer.type 'User'
|
||||
json_maintainer.url api_v1_user_path(@project.maintainer_id, :format => :json)
|
||||
end
|
||||
json.repositories @project.repositories do |json_repos, repo|
|
||||
json_repos.(repo, :id, :name)
|
||||
|
@ -16,6 +20,5 @@ json.project do |json|
|
|||
json_platform.url api_v1_platform_path(repo.platform, :format => :json)
|
||||
end
|
||||
end
|
||||
json.url api_v1_project_path(@project.id, :format => :json)
|
||||
end
|
||||
|
||||
json.url api_v1_project_path(@project, :format => :json)
|
||||
|
|
|
@ -41,10 +41,14 @@ Rosa::Application.routes.draw do
|
|||
put :signatures
|
||||
}
|
||||
end
|
||||
resources :projects, :only => [:show] do
|
||||
resources :projects, :only => [:index, :show, :update, :create, :destroy] do
|
||||
collection { get :get_id }
|
||||
member {
|
||||
get :refs_list
|
||||
get :members
|
||||
put :add_member
|
||||
delete :remove_member
|
||||
put :update_member
|
||||
}
|
||||
end
|
||||
resources :users, :only => [:show]
|
||||
|
|
Loading…
Reference in New Issue