diff --git a/app/controllers/api/v1/projects_controller.rb b/app/controllers/api/v1/projects_controller.rb index 7f9182563..ae7c560ee 100644 --- a/app/controllers/api/v1/projects_controller.rb +++ b/app/controllers/api/v1/projects_controller.rb @@ -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 diff --git a/app/views/api/v1/projects/index.json.jbuilder b/app/views/api/v1/projects/index.json.jbuilder index 9e0ee3956..3a0d4728e 100644 --- a/app/views/api/v1/projects/index.json.jbuilder +++ b/app/views/api/v1/projects/index.json.jbuilder @@ -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) +json.url api_v1_projects_path(:format => :json) \ No newline at end of file diff --git a/app/views/api/v1/projects/show.json.jbuilder b/app/views/api/v1/projects/show.json.jbuilder index 553c586c5..e58b1f812 100644 --- a/app/views/api/v1/projects/show.json.jbuilder +++ b/app/views/api/v1/projects/show.json.jbuilder @@ -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 -end - -json.url api_v1_project_path(@project, :format => :json) + json.url api_v1_project_path(@project.id, :format => :json) +end \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index bd1691c70..b6dc0902e 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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]