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
071d1922
Commit
071d1922
authored
Apr 10, 2017
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
stash it
parent
95e64d78
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
63 additions
and
65 deletions
+63
-65
asset_list.html
apps/assets/templates/assets/asset_list.html
+0
-17
_base_list.html
apps/templates/_base_list.html
+1
-1
forms.py
apps/users/forms.py
+7
-2
group.py
apps/users/models/group.py
+1
-0
_user_bulk_update_modal.html
apps/users/templates/users/_user_bulk_update_modal.html
+29
-29
_user_import_modal.html
apps/users/templates/users/_user_import_modal.html
+2
-1
user_list.html
apps/users/templates/users/user_list.html
+11
-3
user.py
apps/users/views/user.py
+12
-12
No files found.
apps/assets/templates/assets/asset_list.html
View file @
071d1922
...
...
@@ -27,23 +27,6 @@
</div>
{% endblock %}
{% block tags_list %}
<div
class=
"ydxbd"
id=
"ydxbd"
style=
"display: none;"
>
<div
class=
"tagBtnList"
>
{% for tag in tag_list %}
<a
href=
"{% url 'assets:asset-tags' tag_id=tag.0 %}"
{%
if
tag
.
0 =
=
tag_id
%}
class=
"tagBtn2 label label-warning"
name=
"tag_on"
>
{% else %}
class="tagBtn2 label label-default">
{% endif %}
{{ tag.1}}({{ tag.2 }})
</a>
{% endfor %}
<a
href=
"{% url 'assets:asset-list' %}"
class=
"tagBtn2 label label-default"
>
移除选择
</a>
</div>
</div>
{% endblock %}
{% block table_container %}
<div
class=
"uc pull-left m-l-5 m-r-5"
><a
href=
"{% url "
assets:asset-create
"
%}"
class=
"btn btn-sm btn-primary"
>
{% trans "Create asset" %}
</a></div>
...
...
apps/templates/_base_list.html
View file @
071d1922
...
...
@@ -3,7 +3,7 @@
{% load i18n %}
{% block custom_head_css_js %}
<link
href=
"{% static "
css
/
plugins
/
dataTables
/
datatables
.
min
.
css
"
%}"
rel=
"stylesheet"
>
<link
href=
"{% static "
css
/
plugins
/
awesome-bootstrap-checkbox
/
awesome-bootstrap-checkbox
.
css
"
%}"
rel=
"stylesheet"
>
{#
<link
href=
"{% static "
css
/
plugins
/
awesome-bootstrap-checkbox
/
awesome-bootstrap-checkbox
.
css
"
%}"
rel=
"stylesheet"
>
#}
<link
href=
"{% static "
css
/
plugins
/
select2
/
select2
.
min
.
css
"
%}"
rel=
"stylesheet"
>
<script
src=
"{% static "
js
/
plugins
/
select2
/
select2
.
full
.
min
.
js
"
%}"
></script>
<script
src=
"{% static "
js
/
plugins
/
dataTables
/
dataTables
.
min
.
js
"
%}"
></script>
...
...
apps/users/forms.py
View file @
071d1922
...
...
@@ -114,10 +114,15 @@ class UserPublicKeyForm(forms.Form):
return
self
.
instance
class
UserBulkImportForm
(
forms
.
ModelForm
):
# class UserBulkImportForm(forms.ModelForm):
# class Meta:
# model = User
# fields = ['username', 'email', 'enable_otp', 'role']
class
UserBulkUpdateForm
(
forms
.
ModelForm
):
class
Meta
:
model
=
User
fields
=
[
'
username'
,
'email'
,
'enable_otp'
,
'role
'
]
fields
=
[
'
role'
,
'groups'
,
'date_expired'
,
'is_active'
,
'enable_otp
'
]
class
UserGroupForm
(
forms
.
ModelForm
):
...
...
apps/users/models/group.py
View file @
071d1922
...
...
@@ -23,6 +23,7 @@ class UserGroup(NoDeleteModelMixin):
def
__unicode__
(
self
):
return
self
.
name
__str__
=
__unicode__
def
delete
(
self
,
using
=
None
,
keep_parents
=
False
):
self
.
group_ptr
.
delete
()
...
...
apps/users/templates/users/_user_bulk_update_modal.html
View file @
071d1922
{% extends '_modal.html' %}
{% load i18n %}
{% load bootstrap3 %}
{% block modal_id %}user_bulk_update_modal{% endblock %}
{% block modal_title%}{% trans "Update User" %}{% endblock %}
{% block modal_class %}modal-lg{% endblock %}
{% block modal_title%}{% trans "Update selected user" %}{% endblock %}
{% block modal_body %}
<p
class=
"text-success text-center"
>
{% trans "Hint: only change the field you want to update." %}
</p>
<form
method=
"post"
class=
"form-horizontal"
action=
""
id=
"fm_user_bulk_update"
>
<div
class=
"form-group"
>
<label
class=
"control-label col-sm-2 col-lg-2 "
for=
"id_role"
>
{% trans "Role" %}
</label>
<div
class=
" col-sm-9 col-lg-9 "
>
<select
class=
" form-control"
id=
"id_role"
name=
"role"
>
<option
value=
""
>
---------
</option>
<option
value=
"Admin"
>
{% trans "Admin" %}
</option>
<option
value=
"User"
>
{% trans "User" %}
</option>
</select>
</div>
</div>
<div
class=
"form-group"
>
<label
for=
"groups"
class=
"col-sm-2 control-label"
>
{% trans 'Groups' %}
</label>
<div
class=
"col-sm-9"
id=
"select2-container"
>
<select
name=
"groups"
id=
"select2_groups"
data-placeholder=
"{% trans 'Select groups' %}"
class=
"select2 form-control m-b"
multiple
>
{% for group in groups %}
<option
value=
"{{ group.id }}"
>
{{ group.name }}
</option>
{% endfor %}
</select>
</div>
</div>
<div
class=
"form-group"
>
<div
class=
"col-sm-9 col-lg-9 col-sm-offset-2"
>
<div
class=
"checkbox"
>
<input
type=
"checkbox"
name=
"enable_otp"
checked
id=
"id_enable_otp"
><label
for=
"id_enable_otp"
>
{% trans 'Enable-OTP' %}
</label>
</div>
</div>
<div
class=
"ydxbd"
id=
"ydxbd"
style=
"display: block;"
>
<div>
<p
id=
"tags_p"
>
<a
href=
"/assets/asset-by-tag/5"
>
<span
class=
"label label-default"
>
三年质保(0)
</span>
</a>
<a
href=
"/assets/asset-by-tag/5"
>
<span
class=
"label label-default"
>
三年质保(0)
</span>
</a>
</p>
</div>
</div>
<form
method=
"post"
class=
"form-horizontal"
action=
""
id=
"fm_user_bulk_update"
>
{# {% for field in form %}#}
{#
<input
type=
"checkbox"
>
#}
{# {% bootstrap_field field layout='horizontal' %}#}
{# {% endfor %}#}
{% bootstrap_form form layout='horizontal' %}
{#
<div
class=
"form-group"
>
#}
{#
<div
class=
"col-sm-9 col-lg-9 col-sm-offset-2"
>
#}
{#
<div
class=
"checkbox"
>
#}
{#
<input
type=
"checkbox"
name=
"enable_otp"
checked
id=
"id_enable_otp"
disabled
><label
for=
"id_enable_otp"
>
{% trans 'Enable-OTP' %}
</label>
#}
{#
</div>
#}
{#
</div>
#}
{#
</div>
#}
</form>
{% endblock %}
{% block modal_confirm_id %}btn_user_bulk_update{% endblock %}
apps/users/templates/users/_user_import_modal.html
View file @
071d1922
...
...
@@ -8,11 +8,12 @@
{% csrf_token %}
<div
class=
"form-group"
>
<label
class=
"control-label"
for=
"id_users"
>
{% trans "Template" %}
</label>
<a
href=
"{
{ MEDIA_URL }}files/user_import_template.xlsx
"
style=
"display: block"
>
{% trans 'Download' %}
</a>
<a
href=
"{
% url 'users:user-export' %}
"
style=
"display: block"
>
{% trans 'Download' %}
</a>
</div>
<div
class=
"form-group"
>
<label
class=
"control-label"
for=
"id_users"
>
{% trans "Users excel file" %}
</label>
<input
id=
"id_users"
type=
"file"
name=
"file"
/>
<span
class=
"help-block"
>
{% trans 'If set id, will use this id update existed' %}
</span>
</div>
</form>
<p>
...
...
apps/users/templates/users/user_list.html
View file @
071d1922
...
...
@@ -55,7 +55,8 @@
{% block custom_foot_js %}
<script
src=
"{% static 'js/jquery.form.min.js' %}"
></script>
<script>
$
(
document
).
ready
(
function
(){
function
renderTable
()
{
var
options
=
{
ele
:
$
(
'#user_list_table'
),
columnDefs
:
[
...
...
@@ -91,7 +92,13 @@ $(document).ready(function(){
op_html
:
$
(
'#actions'
).
html
()
};
var
table
=
jumpserver
.
initDataTable
(
options
);
}
$
(
document
).
ready
(
function
(){
renderTable
();
var
fields
=
$
(
'#fm_user_bulk_update .form-group'
);
$
.
each
(
fields
,
function
(
index
,
value
)
{
console
.
log
(
value
)
});
$
(
'.btn_export'
).
click
(
function
()
{
var
users
=
[];
var
rows
=
table
.
rows
(
'.selected'
).
data
();
...
...
@@ -242,7 +249,8 @@ $(document).ready(function(){
$
(
'#user_list_table'
).
DataTable
().
ajax
.
reload
();
jumpserver
.
checked
=
false
;
};
APIUpdateAttr
({
url
:
the_url
,
method
:
'PATCH'
,
body
:
JSON
.
stringify
(
post_list
),
success
:
success
});
console
.
log
(
body
);
{
#
APIUpdateAttr
({
url
:
the_url
,
method
:
'PATCH'
,
body
:
JSON
.
stringify
(
post_list
),
success
:
success
});
#
}
$
(
'#user_bulk_update_modal'
).
modal
(
'hide'
);
});
</script>
...
...
apps/users/views/user.py
View file @
071d1922
...
...
@@ -52,7 +52,8 @@ class UserListView(AdminUserRequiredMixin, TemplateView):
context
.
update
({
'app'
:
_
(
'Users'
),
'action'
:
_
(
'User list'
),
'groups'
:
UserGroup
.
objects
.
all
()
'groups'
:
UserGroup
.
objects
.
all
(),
'form'
:
forms
.
UserBulkUpdateForm
(),
})
return
context
...
...
@@ -122,16 +123,16 @@ class UserDetailView(AdminUserRequiredMixin, DetailView):
return
super
(
UserDetailView
,
self
)
.
get_context_data
(
**
kwargs
)
USER_ATTR_MAPPING
=
(
(
'name'
,
'Name'
),
(
'username'
,
'Username'
),
(
'email'
,
'Email'
),
(
'groups'
,
'User groups'
),
(
'role'
,
'Role'
),
(
'phone'
,
'Phone'
),
(
'wechat'
,
'Wechat'
),
(
'comment'
,
'Comment'
),
)
#
USER_ATTR_MAPPING = (
#
('name', 'Name'),
#
('username', 'Username'),
#
('email', 'Email'),
#
('groups', 'User groups'),
#
('role', 'Role'),
#
('phone', 'Phone'),
#
('wechat', 'Wechat'),
#
('comment', 'Comment'),
#
)
@method_decorator
(
csrf_exempt
,
name
=
'dispatch'
)
...
...
@@ -208,7 +209,6 @@ class UserBulkImportView(AdminUserRequiredMixin, JSONResponseMixin, FormView):
mapping_reverse
=
{
field
.
verbose_name
:
field
.
name
for
field
in
fields
}
mapping_reverse
[
_
(
'User groups'
)]
=
'groups'
attr
=
[
mapping_reverse
.
get
(
n
,
None
)
for
n
in
header_
]
print
(
attr
)
if
None
in
attr
:
data
=
{
'valid'
:
False
,
'msg'
:
'Must be same format as '
...
...
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