BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
2179c405
Commit
2179c405
authored
Jul 06, 2016
by
tiagonbotelho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adds basic functionality to the new endpoint of the api
parent
ded67d3b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
19 deletions
+17
-19
entities.rb
lib/api/entities.rb
+6
-2
helpers.rb
lib/api/helpers.rb
+0
-17
projects.rb
lib/api/projects.rb
+11
-0
No files found.
lib/api/entities.rb
View file @
2179c405
...
@@ -91,6 +91,12 @@ module API
...
@@ -91,6 +91,12 @@ 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
...
@@ -353,9 +359,7 @@ module API
...
@@ -353,9 +359,7 @@ module API
class
ProjectWithAccess
<
Project
class
ProjectWithAccess
<
Project
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
.
find_by
(
project
[
:id
])
project
.
project_members
.
find_by
(
user_id:
options
[
:user
].
id
)
project
.
project_members
.
find_by
(
user_id:
options
[
:user
].
id
)
]
end
end
expose
:group_access
,
using:
Entities
::
GroupAccess
do
|
project
,
options
|
expose
:group_access
,
using:
Entities
::
GroupAccess
do
|
project
,
options
|
...
...
lib/api/helpers.rb
View file @
2179c405
...
@@ -287,23 +287,6 @@ module API
...
@@ -287,23 +287,6 @@ module API
# Projects helpers
# Projects helpers
def
filter_params
(
projects
)
project_entries
=
[]
# Removes the redundant information of the object
projects
.
each
do
|
project
|
entry
=
{
id:
project
.
id
,
http_url_to_repo:
project
.
http_url_to_repo
,
name_with_namespace:
project
.
name_with_namespace
}
project_entries
<<
entry
end
project_entries
end
def
filter_projects
(
projects
)
def
filter_projects
(
projects
)
# If the archived parameter is passed, limit results accordingly
# If the archived parameter is passed, limit results accordingly
if
params
[
:archived
].
present?
if
params
[
:archived
].
present?
...
...
lib/api/projects.rb
View file @
2179c405
...
@@ -32,6 +32,17 @@ module API
...
@@ -32,6 +32,17 @@ module API
end
end
end
end
# Get a simplified project list for authenticated user
#
# 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
# Get an owned projects list for authenticated user
# Get an owned projects list for authenticated user
#
#
# Example Request:
# Example Request:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment