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
996ae2df
Commit
996ae2df
authored
10 years ago
by
Gunnar Schaefer
Browse files
Options
Downloads
Patches
Plain Diff
add group creation and deletion routes
parent
02069a2e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
users.py
+28
-5
28 additions, 5 deletions
users.py
with
28 additions
and
5 deletions
users.py
+
28
−
5
View file @
996ae2df
...
...
@@ -181,13 +181,26 @@ class Groups(base.RequestHandler):
"""
/nimsapi/groups
"""
def
__init__
(
self
,
request
=
None
,
response
=
None
):
super
(
Groups
,
self
).
__init__
(
request
,
response
)
self
.
dbc
=
self
.
app
.
db
.
groups
def
count
(
self
):
"""
Return the number of Groups.
"""
self
.
response
.
write
(
self
.
app
.
db
.
groups
.
count
())
def
post
(
self
):
"""
Create a new Group
"""
self
.
response
.
write
(
'
groups post
\n
'
)
if
not
self
.
superuser_request
:
self
.
abort
(
403
,
'
must be superuser to create new group
'
)
try
:
json_body
=
self
.
request
.
json_body
jsonschema
.
validate
(
json_body
,
Group
.
json_schema
)
self
.
dbc
.
insert
(
json_body
)
except
(
ValueError
,
jsonschema
.
ValidationError
)
as
e
:
self
.
abort
(
400
,
str
(
e
))
except
pymongo
.
errors
.
DuplicateKeyError
as
e
:
self
.
abort
(
400
,
'
Groups ID %s already exists
'
%
json_body
[
'
_id
'
])
def
get
(
self
,
_id
=
None
):
"""
Return the list of Groups.
"""
...
...
@@ -219,7 +232,7 @@ class Group(base.RequestHandler):
'
type
'
:
'
object
'
,
'
properties
'
:
{
'
_id
'
:
{
'
title
'
:
'
Database
ID
'
,
'
title
'
:
'
Group
ID
'
,
'
type
'
:
'
string
'
,
},
'
name
'
:
{
...
...
@@ -234,14 +247,16 @@ class Group(base.RequestHandler):
'
items
'
:
{
'
type
'
:
'
object
'
,
'
properties
'
:
{
'
_id
'
:
{
'
access
'
:
{
'
type
'
:
'
string
'
,
'
enum
'
:
[
role
[
'
rid
'
]
for
role
in
ROLES
],
},
'
access
'
:
{
'
_id
'
:
{
'
type
'
:
'
string
'
,
'
enum
'
:
[
k
for
k
,
v
in
sorted
(
INTEGER_ROLES
.
iteritems
(),
key
=
lambda
(
k
,
v
):
v
)],
},
},
'
required
'
:
[
'
access
'
,
'
_id
'
],
'
additionalProperties
'
:
False
,
},
'
uniqueItems
'
:
True
,
},
...
...
@@ -249,6 +264,10 @@ class Group(base.RequestHandler):
'
required
'
:
[
'
_id
'
],
}
def
__init__
(
self
,
request
=
None
,
response
=
None
):
super
(
Group
,
self
).
__init__
(
request
,
response
)
self
.
dbc
=
self
.
app
.
db
.
groups
def
get
(
self
,
_id
):
"""
Return Group details.
"""
group
=
self
.
app
.
db
.
groups
.
find_one
({
'
_id
'
:
_id
})
...
...
@@ -266,3 +285,7 @@ class Group(base.RequestHandler):
def
delete
(
self
,
_id
):
"""
Delete an Group.
"""
if
not
self
.
superuser_request
:
self
.
abort
(
403
,
'
must be superuser to delete a Group
'
)
# TODO: block deletion, if group is referenced by any projects
self
.
dbc
.
remove
({
'
_id
'
:
_id
})
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