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
011c1255
Commit
011c1255
authored
Aug 29, 2016
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Modify user active api And Add Token authorization
parent
1a9f90a0
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
23 additions
and
21 deletions
+23
-21
settings.py
apps/jumpserver/settings.py
+2
-0
api.py
apps/users/api.py
+9
-13
serializers.py
apps/users/serializers.py
+6
-0
user_detail.html
apps/users/templates/users/user_detail.html
+1
-4
urls.py
apps/users/urls.py
+5
-4
jumpserver.log
logs/jumpserver.log
+0
-0
No files found.
apps/jumpserver/settings.py
View file @
011c1255
...
...
@@ -53,6 +53,7 @@ INSTALLED_APPS = [
'audits.apps.AuditsConfig'
,
'common.apps.CommonConfig'
,
'rest_framework'
,
'rest_framework.authtoken'
,
'bootstrapform'
,
# 'django.contrib.admin',
'django.contrib.auth'
,
...
...
@@ -247,6 +248,7 @@ REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES'
:
(
'rest_framework.authentication.BasicAuthentication'
,
'rest_framework.authentication.SessionAuthentication'
,
'rest_framework.authentication.TokenAuthentication'
,
),
}
# This setting is required to override the Django's main loop, when running in
...
...
apps/users/api.py
View file @
011c1255
...
...
@@ -7,7 +7,7 @@ from rest_framework import generics, mixins, status, permissions
from
rest_framework.views
import
APIView
from
rest_framework.response
import
Response
from
.serializers
import
UserSerializer
,
UserGroupSerializer
from
.serializers
import
UserSerializer
,
UserGroupSerializer
,
UserActiveSerializer
from
.models
import
User
,
UserGroup
...
...
@@ -18,24 +18,20 @@ class UserListAddApi(generics.ListCreateAPIView):
queryset
=
User
.
objects
.
all
()
serializer_class
=
UserSerializer
# permission_classes = (
# permissions.DenyAll,
# )
class
UserDetailDeleteUpdateApi
(
generics
.
RetrieveUpdateDestroyAPIView
):
queryset
=
User
.
objects
.
all
()
serializer_class
=
UserSerializer
def
put
(
self
,
request
,
*
args
,
**
kwargs
):
for
k
,
v
in
request
.
META
.
items
():
logger
.
debug
(
"
%
s -->
%
s"
%
(
k
,
v
))
return
super
(
UserDetailDeleteUpdateApi
,
self
)
.
put
(
request
,
*
args
,
**
kwargs
)
# def get(self, request, *args, **kwargs):
# print("hello world")
# print(request.user)
# return super(UserDetailDeleteUpdateApi, self).get(request, *args, **kwargs)
class
UserActiveApi
(
generics
.
RetrieveUpdateDestroyAPIView
):
queryset
=
User
.
objects
.
all
()
serializer_class
=
UserActiveSerializer
# def put(self, request, *args, **kwargs):
# for k, v in request.META.items():
# logger.debug("%s --> %s" % (k, v))
# return super(UserActiveApi, self).put(request, *args, **kwargs)
class
UserGroupListAddApi
(
generics
.
ListCreateAPIView
):
...
...
apps/users/serializers.py
View file @
011c1255
...
...
@@ -17,6 +17,12 @@ class UserSerializer(serializers.ModelSerializer):
]
class
UserActiveSerializer
(
serializers
.
ModelSerializer
):
class
Meta
:
model
=
User
fields
=
[
'is_active'
]
class
UserGroupSerializer
(
serializers
.
ModelSerializer
):
users
=
serializers
.
HyperlinkedRelatedField
(
many
=
True
,
read_only
=
True
,
view_name
=
'users:user-detail-api'
)
...
...
apps/users/templates/users/user_detail.html
View file @
011c1255
...
...
@@ -231,12 +231,9 @@
var
status
=
$
(
obj
).
prop
(
'checked'
);
$
.
ajax
({
url
:
"{% url 'users:user-detail-api' pk=user.id %}"
,
{
#
url
:
"{% url 'users:login' %}"
,
#
}
url
:
"{% url 'users:user-active-api' pk=user.id %}"
,
type
:
"PUT"
,
data
:
{
'username'
:
"{{ user.username }}"
,
'email'
:
"{{ user.email }}"
,
'is_active'
:
status
},
success
:
function
(
data
,
status
)
{
...
...
apps/users/urls.py
View file @
011c1255
...
...
@@ -22,8 +22,9 @@ urlpatterns = [
urlpatterns
+=
[
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'
),
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/users/(?P<pk>[0-9]+)/active$'
,
api
.
UserActiveApi
.
as_view
(),
name
=
'user-active-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'
),
]
logs/jumpserver.log
0 → 100644
View file @
011c1255
This diff is collapsed.
Click to expand it.
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