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
31a39be9
Commit
31a39be9
authored
Aug 30, 2016
by
ibuler
Browse files
Options
Browse Files
Download
Plain Diff
Resolve conflicts
parents
2022ca8e
011c1255
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
26 additions
and
18 deletions
+26
-18
.gitignore
.gitignore
+1
-0
settings.py
apps/jumpserver/settings.py
+2
-0
api.py
apps/users/api.py
+11
-10
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.
.gitignore
View file @
31a39be9
...
...
@@ -15,3 +15,4 @@ migrations/
db.sqlite3
config.py
*/migrations/*
*.log
apps/jumpserver/settings.py
View file @
31a39be9
...
...
@@ -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 @
31a39be9
...
...
@@ -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,20 +18,11 @@ 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
delete
(
self
,
request
,
*
args
,
**
kwargs
):
print
(
self
.
request
.
data
)
return
super
(
UserDetailDeleteUpdateApi
,
self
)
.
delete
(
request
,
*
args
,
**
kwargs
)
...
...
@@ -42,6 +33,16 @@ class UserDetailDeleteUpdateApi(generics.RetrieveUpdateDestroyAPIView):
# 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
):
queryset
=
UserGroup
.
objects
.
all
()
serializer_class
=
UserGroupSerializer
...
...
apps/users/serializers.py
View file @
31a39be9
...
...
@@ -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 @
31a39be9
...
...
@@ -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 @
31a39be9
...
...
@@ -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 @
31a39be9
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