Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to JiHu GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Chenhao Ma
core
Commits
0ca18aa6
Commit
0ca18aa6
authored
7 years ago
by
Harsha Kethineni
Browse files
Options
Downloads
Patches
Plain Diff
groups join=projects parameter
parent
febf00cf
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
api/dao/base.py
+7
-2
7 additions, 2 deletions
api/dao/base.py
api/handlers/grouphandler.py
+11
-0
11 additions, 0 deletions
api/handlers/grouphandler.py
test/integration_tests/python/test_groups.py
+6
-0
6 additions, 0 deletions
test/integration_tests/python/test_groups.py
with
24 additions
and
2 deletions
api/dao/base.py
+
7
−
2
View file @
0ca18aa6
...
...
@@ -80,12 +80,17 @@ class ContainerStorage(object):
cont
[
CHILD_MAP
[
self
.
cont_name
]]
=
children
return
cont
def
get_children
(
self
,
_id
,
projection
=
None
):
def
get_children
(
self
,
_id
,
projection
=
None
,
uid
=
None
):
try
:
child_name
=
CHILD_MAP
[
self
.
cont_name
]
except
KeyError
:
raise
APINotFoundException
(
'
Children cannot be listed from the {0} level
'
.
format
(
self
.
cont_name
))
query
=
{
self
.
cont_name
[:
-
1
]:
bson
.
ObjectId
(
_id
)}
if
self
.
cont_name
==
'
groups
'
:
query
=
{
self
.
cont_name
[:
-
1
]:
_id
}
if
uid
:
query
[
'
permissions
'
]
=
{
'
$elemMatch
'
:
{
'
_id
'
:
uid
}}
else
:
query
=
{
self
.
cont_name
[:
-
1
]:
bson
.
ObjectId
(
_id
)}
if
not
projection
:
projection
=
{
'
info
'
:
0
,
'
files.info
'
:
0
,
'
subject
'
:
0
,
'
tags
'
:
0
}
return
ContainerStorage
.
factory
(
child_name
).
get_all_el
(
query
,
None
,
projection
)
...
...
This diff is collapsed.
Click to expand it.
api/handlers/grouphandler.py
+
11
−
0
View file @
0ca18aa6
...
...
@@ -36,6 +36,14 @@ class GroupHandler(base.RequestHandler):
self
.
abort
(
404
,
'
Group {} not removed
'
.
format
(
_id
))
return
result
def
handle_projects
(
self
,
result
):
"""
If parameter join=projects, return project id, label, permissions, and description
"""
result
[
'
projects
'
]
=
self
.
storage
.
get_children
(
result
.
get
(
'
_id
'
),
projection
=
{
'
permissions
'
:
1
,
'
label
'
:
1
,
'
description
'
:
1
},
uid
=
self
.
uid
)
self
.
_filter_permissions
(
result
[
'
projects
'
],
self
.
uid
)
return
result
def
get_all
(
self
,
uid
=
None
):
projection
=
{
'
label
'
:
1
,
'
created
'
:
1
,
'
modified
'
:
1
,
'
permissions
'
:
1
,
'
tags
'
:
1
}
permchecker
=
groupauth
.
list_permission_checker
(
self
,
uid
)
...
...
@@ -44,6 +52,9 @@ class GroupHandler(base.RequestHandler):
self
.
_filter_permissions
(
results
,
self
.
uid
)
if
self
.
is_true
(
'
join_avatars
'
):
results
=
ContainerHandler
.
join_user_info
(
results
)
if
'
projects
'
in
self
.
request
.
params
.
getall
(
'
join
'
):
for
result
in
results
:
result
=
self
.
handle_projects
(
result
)
return
results
@validators.verify_payload_exists
...
...
This diff is collapsed.
Click to expand it.
test/integration_tests/python/test_groups.py
+
6
−
0
View file @
0ca18aa6
...
...
@@ -118,3 +118,9 @@ def test_groups(as_user, as_admin, data_builder):
r
=
as_admin
.
get
(
'
/groups/
'
+
group
)
assert
r
.
ok
assert
r
.
json
()[
'
label
'
]
==
group_label
# Test join=projects
project
=
data_builder
.
create_project
()
r
=
as_admin
.
get
(
'
/groups
'
,
params
=
{
'
join
'
:
'
projects
'
})
assert
r
.
ok
assert
r
.
json
()[
1
].
get
(
'
projects
'
)[
0
].
get
(
'
_id
'
)
==
project
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment