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
c6f875c5
Commit
c6f875c5
authored
Sep 06, 2016
by
xiaoyu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
temp commit
parent
07dd6d11
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
39 additions
and
11 deletions
+39
-11
toastr.min.js
apps/static/js/plugins/toastr/toastr.min.js
+3
-0
_foot_js.html
apps/templates/_foot_js.html
+5
-5
api.py
apps/users/api.py
+6
-4
serializers.py
apps/users/serializers.py
+8
-0
user_detail.html
apps/users/templates/users/user_detail.html
+15
-2
urls.py
apps/users/urls.py
+2
-0
No files found.
apps/static/js/plugins/toastr/toastr.min.js
0 → 100644
View file @
c6f875c5
!
function
(
e
){
e
([
"jquery"
],
function
(
e
){
return
function
(){
function
t
(
e
,
t
,
n
){
return
f
({
type
:
O
.
error
,
iconClass
:
g
().
iconClasses
.
error
,
message
:
e
,
optionsOverride
:
n
,
title
:
t
})}
function
n
(
t
,
n
){
return
t
||
(
t
=
g
()),
v
=
e
(
"#"
+
t
.
containerId
),
v
.
length
?
v
:(
n
&&
(
v
=
c
(
t
)),
v
)}
function
i
(
e
,
t
,
n
){
return
f
({
type
:
O
.
info
,
iconClass
:
g
().
iconClasses
.
info
,
message
:
e
,
optionsOverride
:
n
,
title
:
t
})}
function
o
(
e
){
w
=
e
}
function
s
(
e
,
t
,
n
){
return
f
({
type
:
O
.
success
,
iconClass
:
g
().
iconClasses
.
success
,
message
:
e
,
optionsOverride
:
n
,
title
:
t
})}
function
a
(
e
,
t
,
n
){
return
f
({
type
:
O
.
warning
,
iconClass
:
g
().
iconClasses
.
warning
,
message
:
e
,
optionsOverride
:
n
,
title
:
t
})}
function
r
(
e
){
var
t
=
g
();
v
||
n
(
t
),
l
(
e
,
t
)
||
u
(
t
)}
function
d
(
t
){
var
i
=
g
();
return
v
||
n
(
i
),
t
&&
0
===
e
(
":focus"
,
t
).
length
?
void
h
(
t
):
void
(
v
.
children
().
length
&&
v
.
remove
())}
function
u
(
t
){
for
(
var
n
=
v
.
children
(),
i
=
n
.
length
-
1
;
i
>=
0
;
i
--
)
l
(
e
(
n
[
i
]),
t
)}
function
l
(
t
,
n
){
return
t
&&
0
===
e
(
":focus"
,
t
).
length
?(
t
[
n
.
hideMethod
]({
duration
:
n
.
hideDuration
,
easing
:
n
.
hideEasing
,
complete
:
function
(){
h
(
t
)}}),
!
0
):
!
1
}
function
c
(
t
){
return
v
=
e
(
"<div/>"
).
attr
(
"id"
,
t
.
containerId
).
addClass
(
t
.
positionClass
).
attr
(
"aria-live"
,
"polite"
).
attr
(
"role"
,
"alert"
),
v
.
appendTo
(
e
(
t
.
target
)),
v
}
function
p
(){
return
{
tapToDismiss
:
!
0
,
toastClass
:
"toast"
,
containerId
:
"toast-container"
,
debug
:
!
1
,
showMethod
:
"fadeIn"
,
showDuration
:
300
,
showEasing
:
"swing"
,
onShown
:
void
0
,
hideMethod
:
"fadeOut"
,
hideDuration
:
1
e3
,
hideEasing
:
"swing"
,
onHidden
:
void
0
,
extendedTimeOut
:
1
e3
,
iconClasses
:{
error
:
"toast-error"
,
info
:
"toast-info"
,
success
:
"toast-success"
,
warning
:
"toast-warning"
},
iconClass
:
"toast-info"
,
positionClass
:
"toast-top-right"
,
timeOut
:
5
e3
,
titleClass
:
"toast-title"
,
messageClass
:
"toast-message"
,
target
:
"body"
,
closeHtml
:
'<button type="button">×</button>'
,
newestOnTop
:
!
0
,
preventDuplicates
:
!
1
,
progressBar
:
!
1
}}
function
m
(
e
){
w
&&
w
(
e
)}
function
f
(
t
){
function
i
(
t
){
return
!
e
(
":focus"
,
l
).
length
||
t
?(
clearTimeout
(
O
.
intervalId
),
l
[
r
.
hideMethod
]({
duration
:
r
.
hideDuration
,
easing
:
r
.
hideEasing
,
complete
:
function
(){
h
(
l
),
r
.
onHidden
&&
"hidden"
!==
b
.
state
&&
r
.
onHidden
(),
b
.
state
=
"hidden"
,
b
.
endTime
=
new
Date
,
m
(
b
)}})):
void
0
}
function
o
(){(
r
.
timeOut
>
0
||
r
.
extendedTimeOut
>
0
)
&&
(
u
=
setTimeout
(
i
,
r
.
extendedTimeOut
),
O
.
maxHideTime
=
parseFloat
(
r
.
extendedTimeOut
),
O
.
hideEta
=
(
new
Date
).
getTime
()
+
O
.
maxHideTime
)}
function
s
(){
clearTimeout
(
u
),
O
.
hideEta
=
0
,
l
.
stop
(
!
0
,
!
0
)[
r
.
showMethod
]({
duration
:
r
.
showDuration
,
easing
:
r
.
showEasing
})}
function
a
(){
var
e
=
(
O
.
hideEta
-
(
new
Date
).
getTime
())
/
O
.
maxHideTime
*
100
;
f
.
width
(
e
+
"%"
)}
var
r
=
g
(),
d
=
t
.
iconClass
||
r
.
iconClass
;
if
(
"undefined"
!=
typeof
t
.
optionsOverride
&&
(
r
=
e
.
extend
(
r
,
t
.
optionsOverride
),
d
=
t
.
optionsOverride
.
iconClass
||
d
),
r
.
preventDuplicates
){
if
(
t
.
message
===
C
)
return
;
C
=
t
.
message
}
T
++
,
v
=
n
(
r
,
!
0
);
var
u
=
null
,
l
=
e
(
"<div/>"
),
c
=
e
(
"<div/>"
),
p
=
e
(
"<div/>"
),
f
=
e
(
"<div/>"
),
w
=
e
(
r
.
closeHtml
),
O
=
{
intervalId
:
null
,
hideEta
:
null
,
maxHideTime
:
null
},
b
=
{
toastId
:
T
,
state
:
"visible"
,
startTime
:
new
Date
,
options
:
r
,
map
:
t
};
return
t
.
iconClass
&&
l
.
addClass
(
r
.
toastClass
).
addClass
(
d
),
t
.
title
&&
(
c
.
append
(
t
.
title
).
addClass
(
r
.
titleClass
),
l
.
append
(
c
)),
t
.
message
&&
(
p
.
append
(
t
.
message
).
addClass
(
r
.
messageClass
),
l
.
append
(
p
)),
r
.
closeButton
&&
(
w
.
addClass
(
"toast-close-button"
).
attr
(
"role"
,
"button"
),
l
.
prepend
(
w
)),
r
.
progressBar
&&
(
f
.
addClass
(
"toast-progress"
),
l
.
prepend
(
f
)),
l
.
hide
(),
r
.
newestOnTop
?
v
.
prepend
(
l
):
v
.
append
(
l
),
l
[
r
.
showMethod
]({
duration
:
r
.
showDuration
,
easing
:
r
.
showEasing
,
complete
:
r
.
onShown
}),
r
.
timeOut
>
0
&&
(
u
=
setTimeout
(
i
,
r
.
timeOut
),
O
.
maxHideTime
=
parseFloat
(
r
.
timeOut
),
O
.
hideEta
=
(
new
Date
).
getTime
()
+
O
.
maxHideTime
,
r
.
progressBar
&&
(
O
.
intervalId
=
setInterval
(
a
,
10
))),
l
.
hover
(
s
,
o
),
!
r
.
onclick
&&
r
.
tapToDismiss
&&
l
.
click
(
i
),
r
.
closeButton
&&
w
&&
w
.
click
(
function
(
e
){
e
.
stopPropagation
?
e
.
stopPropagation
():
void
0
!==
e
.
cancelBubble
&&
e
.
cancelBubble
!==!
0
&&
(
e
.
cancelBubble
=!
0
),
i
(
!
0
)}),
r
.
onclick
&&
l
.
click
(
function
(){
r
.
onclick
(),
i
()}),
m
(
b
),
r
.
debug
&&
console
&&
console
.
log
(
b
),
l
}
function
g
(){
return
e
.
extend
({},
p
(),
b
.
options
)}
function
h
(
e
){
v
||
(
v
=
n
()),
e
.
is
(
":visible"
)
||
(
e
.
remove
(),
e
=
null
,
0
===
v
.
children
().
length
&&
(
v
.
remove
(),
C
=
void
0
))}
var
v
,
w
,
C
,
T
=
0
,
O
=
{
error
:
"error"
,
info
:
"info"
,
success
:
"success"
,
warning
:
"warning"
},
b
=
{
clear
:
r
,
remove
:
d
,
error
:
t
,
getContainer
:
n
,
info
:
i
,
options
:{},
subscribe
:
o
,
success
:
s
,
version
:
"2.1.0"
,
warning
:
a
};
return
b
}()})}(
"function"
==
typeof
define
&&
define
.
amd
?
define
:
function
(
e
,
t
){
"undefined"
!=
typeof
module
&&
module
.
exports
?
module
.
exports
=
t
(
require
(
"jquery"
)):
window
.
toastr
=
t
(
window
.
jQuery
)});
//# sourceMappingURL=/toastr.js.map
\ No newline at end of file
apps/templates/_foot_js.html
View file @
c6f875c5
{% load static %}
<!-- Mainly scripts -->
<script
src=
"{% static "
js
/
plugins
/
metisMenu
/
jquery
.
metisMenu
.
js
"
%}"
></script>
<script
src=
"{% static "
js
/
plugins
/
toastr
/
toastr
.
min
.
js
"
%}"
></script>
<!-- Custom and plugin javascript -->
<script
src=
"{% static "
js
/
inspinia
.
js
"
%}"
></script>
<script
src=
"{% static "
js
/
jumpserver
.
js
"
%}"
></script>
<script>
<!--
active
menu
-->
// active menu
var
url_array
=
document
.
location
.
pathname
.
split
(
"/"
);
app
=
url_array
[
1
];
resource
=
url_array
[
2
];
...
...
@@ -18,7 +19,7 @@
$
(
'#'
+
app
+
' #'
+
resource
).
addClass
(
'active'
);
}
<!--
ajax
set
cookie
-->
// ajax set cookie
function
getCookie
(
name
)
{
var
cookieValue
=
null
;
if
(
document
.
cookie
&&
document
.
cookie
!==
''
)
{
...
...
@@ -51,6 +52,6 @@
}
});
<!--
textarea
rows
-->
// textarea rows
$
(
'textarea'
).
attr
(
'rows'
,
5
)
</script>
\ No newline at end of file
</script>
apps/users/api.py
View file @
c6f875c5
...
...
@@ -3,11 +3,9 @@
import
logging
from
rest_framework
import
generics
,
mixins
,
status
,
permissions
from
rest_framework.views
import
APIView
from
rest_framework.response
import
Response
from
rest_framework
import
generics
from
.serializers
import
UserSerializer
,
UserGroupSerializer
,
UserActiveSerializer
from
.serializers
import
UserSerializer
,
UserGroupSerializer
,
UserActiveSerializer
,
UserAttributeSerializer
from
.models
import
User
,
UserGroup
...
...
@@ -52,3 +50,7 @@ class UserGroupDetailDeleteUpdateApi(generics.RetrieveUpdateDestroyAPIView):
queryset
=
UserGroup
.
objects
.
all
()
serializer_class
=
UserGroupSerializer
class
UserAttributeApi
(
generics
.
RetrieveUpdateDestroyAPIView
):
queryset
=
User
.
objects
.
all
()
serializer_class
=
UserAttributeSerializer
apps/users/serializers.py
View file @
c6f875c5
...
...
@@ -18,6 +18,7 @@ class UserSerializer(serializers.ModelSerializer):
class
UserActiveSerializer
(
serializers
.
ModelSerializer
):
class
Meta
:
model
=
User
fields
=
[
'is_active'
]
...
...
@@ -29,3 +30,10 @@ class UserGroupSerializer(serializers.ModelSerializer):
class
Meta
:
model
=
UserGroup
fields
=
'__all__'
class
UserAttributeSerializer
(
serializers
.
ModelSerializer
):
class
Meta
:
model
=
User
fields
=
[
'avatar'
,
'wechat'
,
'phone'
,
'enable_otp'
,
'comment'
,
'is_active'
,
'name'
]
apps/users/templates/users/user_detail.html
View file @
c6f875c5
...
...
@@ -223,6 +223,20 @@
{% endblock %}
{% block custom_foot_js %}
<script>
function
api_update_attr
(
url
,
body
,
method
,
success
,
error
)
{
$
.
ajax
({
url
:
url
,
type
:
method
||
"PATCH"
,
data
:
body
}).
done
(
function
(
data
)
{
if
(
typeof
success
====
'function'
)
{
return
success
(
data
)
}
else
{
}
})
}
function
switch_user_status
(
obj
)
{
var
status
=
$
(
obj
).
prop
(
'checked'
);
...
...
@@ -244,4 +258,4 @@
$
(
'.select2'
).
select2
();
})
</script>
{% endblock %}
\ No newline at end of file
{% endblock %}
apps/users/urls.py
View file @
c6f875c5
...
...
@@ -31,6 +31,8 @@ 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/users/(?P<pk>[0-9]+)/patch$'
,
api
.
UserAttributeApi
.
as_view
(),
name
=
'user-patch-api'
),
url
(
r'^v1/users/(?P<pk>[0-9]+)/active$'
,
api
.
UserActiveApi
.
as_view
(),
name
=
'user-active-api'
),
url
(
r'^v1/user-groups$'
,
api
.
UserGroupListAddApi
.
as_view
(),
name
=
'user-group-list-api'
),
url
(
r'^v1/user-groups/(?P<pk>[0-9]+)$'
,
...
...
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