Commit f5d92d12 authored by tiagonbotelho's avatar tiagonbotelho

changes the usage of simpleprojectdetails to already implemented...

changes the usage of simpleprojectdetails to already implemented basicprojectsdetails and changes the url to a more reader friendly format
parent 6715ea7d
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
groupPath: "/api/:version/groups/:id.json" groupPath: "/api/:version/groups/:id.json"
namespacesPath: "/api/:version/namespaces.json" namespacesPath: "/api/:version/namespaces.json"
groupProjectsPath: "/api/:version/groups/:id/projects.json" groupProjectsPath: "/api/:version/groups/:id/projects.json"
projectsPath: "/api/:version/projects/simple.json" projectsPath: "/api/:version/projects.json?format=simple"
labelsPath: "/api/:version/projects/:id/labels" labelsPath: "/api/:version/projects/:id/labels"
licensePath: "/api/:version/licenses/:key" licensePath: "/api/:version/licenses/:key"
gitignorePath: "/api/:version/gitignores/:key" gitignorePath: "/api/:version/gitignores/:key"
......
...@@ -90,12 +90,6 @@ module API ...@@ -90,12 +90,6 @@ module API
end end
end end
class SimpleProject < Grape::Entity
expose :id
expose :name, :name_with_namespace
expose :http_url_to_repo
end
class ProjectMember < UserBasic class ProjectMember < UserBasic
expose :access_level do |user, options| expose :access_level do |user, options|
options[:project].project_members.find_by(user_id: user.id).access_level options[:project].project_members.find_by(user_id: user.id).access_level
...@@ -347,7 +341,7 @@ module API ...@@ -347,7 +341,7 @@ module API
end end
end end
class SimpleProjectWithAccess < SimpleProject class BasicProjectWithAccess < BasicProjectDetails
expose :permissions do expose :permissions do
expose :project_access, using: Entities::ProjectAccess do |project, options| expose :project_access, using: Entities::ProjectAccess do |project, options|
project.project_members.find_by(user_id: options[:user].id) project.project_members.find_by(user_id: options[:user].id)
......
...@@ -25,18 +25,11 @@ module API ...@@ -25,18 +25,11 @@ module API
@projects = current_user.authorized_projects @projects = current_user.authorized_projects
@projects = filter_projects(@projects) @projects = filter_projects(@projects)
@projects = paginate @projects @projects = paginate @projects
present @projects, with: Entities::ProjectWithAccess, user: current_user if params["format"]
end present @projects, with: Entities::BasicProjectWithAccess, user: current_user
else
# Get a simplified project list for authenticated user present @projects, with: Entities::ProjectWithAccess, user: current_user
# end
# Example Request:
# GET /projects/simple
get '/simple' do
@projects = current_user.authorized_projects
@projects = filter_projects(@projects)
@projects = paginate @projects
present @projects, with: Entities::SimpleProjectWithAccess, user: current_user
end end
# Get an owned projects list for authenticated user # Get an owned projects list for authenticated user
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment