Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
J
jumpserver
Project
Project
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ops
jumpserver
Commits
8aa92bb6
Commit
8aa92bb6
authored
Aug 24, 2016
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add api: UserApi And UserGroupApi
parent
1d5faa31
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
12 deletions
+25
-12
api.py
apps/users/api.py
+17
-5
api_urls.py
apps/users/api_urls.py
+6
-5
serializers.py
apps/users/serializers.py
+2
-2
No files found.
apps/users/api.py
View file @
8aa92bb6
# ~*~ coding: utf-8 ~*~
#
from
rest_framework
import
generics
from
rest_framework
import
mixins
from
rest_framework
import
generics
,
mixins
,
status
,
permissions
from
rest_framework.views
import
APIView
from
rest_framework.response
import
Response
from
.serializers
import
UserSerializer
from
.serializers
import
UserSerializer
,
UserGroupSerializer
from
.models
import
User
,
UserGroup
class
UserListApi
(
generics
.
ListCreateAPIView
):
class
UserListA
ddA
pi
(
generics
.
ListCreateAPIView
):
queryset
=
User
.
objects
.
all
()
serializer_class
=
UserSerializer
class
UserDetailApi
(
generics
.
RetrieveUpdateDestroyAPIView
):
class
UserDetail
DeleteUpdate
Api
(
generics
.
RetrieveUpdateDestroyAPIView
):
queryset
=
User
.
objects
.
all
()
serializer_class
=
UserSerializer
class
UserGroupListAddApi
(
generics
.
ListCreateAPIView
):
queryset
=
UserGroup
.
objects
.
all
()
serializer_class
=
UserGroupSerializer
class
UserGroupDetailDeleteUpdateApi
(
generics
.
RetrieveUpdateDestroyAPIView
):
queryset
=
UserGroup
.
objects
.
all
()
serializer_class
=
UserGroupSerializer
apps/users/api_urls.py
View file @
8aa92bb6
...
...
@@ -2,11 +2,12 @@
#
from
django.conf.urls
import
url
,
include
from
.api
import
UserListApi
,
UserDetailApi
import
api
urlpatterns
=
[
url
(
r'^v1/users/$'
,
UserListApi
.
as_view
()),
url
(
r'^v1/users/(?P<pk>[0-9]+)/$'
,
UserDetailApi
.
as_view
()),
url
(
r'^v1/users/$'
,
api
.
UserListAddApi
.
as_view
(),
name
=
'user-list-api'
),
url
(
r'^v1/users/(?P<pk>[0-9]+)/$'
,
api
.
UserDetailDeleteUpdateApi
.
as_view
(),
name
=
'user-detail-api'
),
url
(
r'^v1/usergroups/$'
,
api
.
UserGroupListAddApi
.
as_view
(),
name
=
'usergroup-list-api'
),
url
(
r'^v1/usergroups/(?P<pk>[0-9]+)/$'
,
api
.
UserGroupDetailDeleteUpdateApi
.
as_view
(),
name
=
'usergroup-detail-api'
),
]
apps/users/serializers.py
View file @
8aa92bb6
...
...
@@ -10,8 +10,8 @@ class UserSerializer(serializers.ModelSerializer):
class
Meta
:
model
=
User
exclude
=
[
'password'
,
'first_name'
,
'last_name'
,
'
is_staff'
,
'
secret_key_otp'
,
'private_key'
,
'public_key'
,
'password'
,
'first_name'
,
'last_name'
,
'secret_key_otp'
,
'private_key'
,
'public_key'
,
'avatar'
,
]
...
...
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