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
61d1d9ec
Commit
61d1d9ec
authored
Sep 21, 2016
by
xiaoyu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
temp
parent
22089282
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
42 additions
and
12 deletions
+42
-12
api.py
apps/users/api.py
+7
-1
serializers.py
apps/users/serializers.py
+8
-0
user_list.html
apps/users/templates/users/user_list.html
+26
-11
urls.py
apps/users/urls.py
+1
-0
No files found.
apps/users/api.py
View file @
61d1d9ec
...
...
@@ -4,9 +4,10 @@
import
logging
from
rest_framework
import
generics
from
rest_framework_bulk
import
ListBulkCreateUpdateDestroyAPIView
from
.serializers
import
UserSerializer
,
UserGroupSerializer
,
UserAttributeSerializer
,
UserGroupEditSerializer
,
\
GroupEditSerializer
,
UserPKUpdateSerializer
GroupEditSerializer
,
UserPKUpdateSerializer
,
UserBulkUpdateSerializer
from
.models
import
User
,
UserGroup
...
...
@@ -92,3 +93,8 @@ class UserUpdatePKApi(generics.UpdateAPIView):
class
GroupDeleteApi
(
generics
.
DestroyAPIView
):
queryset
=
UserGroup
.
objects
.
all
()
serializer_class
=
GroupEditSerializer
class
UserBulkUpdateApi
(
ListBulkCreateUpdateDestroyAPIView
):
queryset
=
User
.
objects
.
all
()
serializer_class
=
UserBulkUpdateSerializer
apps/users/serializers.py
View file @
61d1d9ec
...
...
@@ -3,6 +3,7 @@
from
django.utils.translation
import
ugettext_lazy
as
_
from
rest_framework
import
serializers
from
rest_framework_bulk
import
BulkListSerializer
,
BulkSerializerMixin
from
.models
import
User
,
UserGroup
...
...
@@ -67,3 +68,10 @@ class UserPKUpdateSerializer(serializers.ModelSerializer):
print
e
raise
serializers
.
ValidationError
(
_
(
'Not a valid ssh public key'
))
return
value
class
UserBulkUpdateSerializer
(
BulkSerializerMixin
,
serializers
.
ModelSerializer
):
class
Meta
(
object
):
model
=
User
list_serializer_class
=
BulkListSerializer
apps/users/templates/users/user_list.html
View file @
61d1d9ec
...
...
@@ -22,7 +22,7 @@
{% for user in object_list %}
<tr
class=
"gradeX"
>
<td
class=
"text-center"
>
<input
type=
"checkbox"
name=
"checked"
value=
"{{ user.id }}"
>
<input
type=
"checkbox"
name=
"checked"
value=
"{{ user.id }}"
class=
"ipt_bulk_update"
>
</td>
<td
class=
"text-center"
>
<a
href=
"{% url 'users:user-detail' pk=user.id %}"
>
...
...
@@ -50,23 +50,38 @@
{% endblock %}
{% block content_bottom_left %}
<form
id=
""
method=
"get"
action=
""
class=
" mail-search"
>
<div
class=
"input-group"
>
<select
class=
"form-control m-b"
style=
"width: auto"
>
<option>
{% trans 'Delete selected' %}
</option>
<option>
{% trans 'Update selected' %}
</option>
<option>
{% trans 'Deactive selected' %}
</option>
<option>
{% trans 'Export selected' %}
</option>
<select
class=
"form-control m-b"
style=
"width: auto"
id=
"slct_bulk_update"
>
<option
value=
"delete"
>
{% trans 'Delete selected' %}
</option>
<option
value=
"update"
>
{% trans 'Update selected' %}
</option>
<option
value=
"deactive"
>
{% trans 'Deactive selected' %}
</option>
<option
value=
"export"
>
{% trans 'Export selected' %}
</option>
</select>
<div
class=
"input-group-btn pull-left"
style=
"padding-left: 5px;"
>
<button
id=
'
search_btn'
type=
"submit"
style=
"height: 32px;"
class=
"btn btn-sm btn-primary"
>
<button
id=
'
btn_bulk_update'
style=
"height: 32px;"
class=
"btn btn-sm btn-primary"
>
{% trans 'Submit' %}
</button>
</div>
</div>
</form>
{% endblock %}
{% block custom_foot_js %}
<script>
jumpserver
.
bulk_delete
=
function
(){
}
$
(
document
).
on
(
'click'
,
'#btn_bulk_update'
,
function
(){
var
action
=
$
(
'#slct_bulk_update'
).
val
();
var
id_list
=
$
(
'.ipt_bulk_update:checked'
).
map
(
function
(){
return
{
'id'
:
$
(
this
).
val
()}}).
get
();
console
.
log
(
id_list
);
function
doDeactive
()
{
var
body
=
$
.
each
(
id_list
,
function
(
dict
,
index
)
{
})
};
switch
(
action
)
{
case
'deactive'
:
}
})
</script>
{% endblock %}
apps/users/urls.py
View file @
61d1d9ec
...
...
@@ -36,6 +36,7 @@ urlpatterns = [
urlpatterns
+=
[
url
(
r'^v1/users$'
,
api
.
UserListAddApi
.
as_view
(),
name
=
'user-list-api'
),
url
(
r'^v1/users/update/$'
,
api
.
UserBulkUpdateApi
.
as_view
(),
name
=
'user-bulk-update-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$'
,
...
...
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