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
c11374ae
Commit
c11374ae
authored
Apr 07, 2017
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Bugfix] 修改翻译
parent
92ebe85a
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
37 changed files
with
126 additions
and
264 deletions
+126
-264
terminal_detail.html
.../applications/templates/applications/terminal_detail.html
+2
-2
views.py
apps/applications/views.py
+1
-1
forms.py
apps/assets/forms.py
+9
-13
asset.py
apps/assets/models/asset.py
+3
-3
group.py
apps/assets/models/group.py
+1
-1
idc.py
apps/assets/models/idc.py
+1
-1
_asset_bulk_update_modal.html
apps/assets/templates/assets/_asset_bulk_update_modal.html
+4
-4
_asset_group_bulk_update_modal.html
...sets/templates/assets/_asset_group_bulk_update_modal.html
+1
-1
asset_detail.html
apps/assets/templates/assets/asset_detail.html
+7
-7
asset_group_list.html
apps/assets/templates/assets/asset_group_list.html
+2
-2
idc_assets.html
apps/assets/templates/assets/idc_assets.html
+2
-2
idc_list.html
apps/assets/templates/assets/idc_list.html
+1
-1
system_user_asset.html
apps/assets/templates/assets/system_user_asset.html
+16
-16
system_user_asset_group.html
apps/assets/templates/assets/system_user_asset_group.html
+0
-134
system_user_detail.html
apps/assets/templates/assets/system_user_detail.html
+3
-11
admin_user.py
apps/assets/views/admin_user.py
+4
-4
system_user.py
apps/assets/views/system_user.py
+8
-10
settings.py
apps/jumpserver/settings.py
+5
-1
django.po
apps/locale/zh/LC_MESSAGES/django.po
+0
-0
models.py
apps/ops/models.py
+1
-1
task_detail.html
apps/ops/templates/ops/task_detail.html
+1
-1
asset_permission_asset.html
apps/perms/templates/perms/asset_permission_asset.html
+1
-1
views.py
apps/perms/views.py
+13
-10
_base_list.html
apps/templates/_base_list.html
+4
-3
_nav.html
apps/templates/_nav.html
+1
-1
base.html
apps/templates/base.html
+0
-1
forms.py
apps/users/forms.py
+0
-8
group.py
apps/users/models/group.py
+2
-1
_user_bulk_update_modal.html
apps/users/templates/users/_user_bulk_update_modal.html
+1
-1
user_detail.html
apps/users/templates/users/user_detail.html
+5
-5
user_group_create_update.html
apps/users/templates/users/user_group_create_update.html
+1
-1
user_group_detail.html
apps/users/templates/users/user_group_detail.html
+1
-1
user_group_list.html
apps/users/templates/users/user_group_list.html
+3
-2
user_profile.html
apps/users/templates/users/user_profile.html
+1
-1
group.py
apps/users/views/group.py
+12
-2
user.py
apps/users/views/user.py
+8
-8
deb_requirements.txt
requirements/deb_requirements.txt
+1
-2
No files found.
apps/applications/templates/applications/terminal_detail.html
View file @
c11374ae
...
...
@@ -44,11 +44,11 @@
<td><b>
{{ terminal.name }}
</b></td>
</tr>
<tr>
<td>
{% trans 'Remote addr' %}:
</td>
<td>
{% trans 'Remote addr
ess
' %}:
</td>
<td><b>
{{ terminal.remote_addr }}
</b></td>
</tr>
<tr>
<td>
{% trans '
Terminal url
' %}:
</td>
<td>
{% trans '
URL to login
' %}:
</td>
<td><b>
{{ terminal.url }}
</b></td>
</tr>
<tr>
...
...
apps/applications/views.py
View file @
c11374ae
...
...
@@ -97,7 +97,7 @@ class TerminalConnectView(LoginRequiredMixin, DetailView):
if
self
.
object
.
type
==
'Web'
:
context
=
{
'title'
:
_
(
'Redirect to web terminal'
),
'messages'
:
_
(
'Redirect to web terminal
: {}'
.
format
(
self
.
object
.
url
))
,
'messages'
:
_
(
'Redirect to web terminal
'
)
+
self
.
object
.
url
,
'auto_redirect'
:
True
,
'interval'
:
3
,
'redirect_url'
:
self
.
object
.
url
...
...
apps/assets/forms.py
View file @
c11374ae
...
...
@@ -80,13 +80,8 @@ class AssetGroupForm(forms.ModelForm):
class
Meta
:
model
=
AssetGroup
fields
=
[
"name"
,
"comment"
,
"system_users"
,
"name"
,
"comment"
,
]
widgets
=
{
'name'
:
forms
.
TextInput
(
attrs
=
{}),
'system_users'
:
forms
.
SelectMultiple
(
attrs
=
{
'class'
:
'select2-system-user'
,
'data-placeholder'
:
_
(
'Select asset system user'
)}),
}
help_texts
=
{
'name'
:
'* required'
,
}
...
...
@@ -94,12 +89,13 @@ class AssetGroupForm(forms.ModelForm):
class
IDCForm
(
forms
.
ModelForm
):
# See AdminUserForm comment same it
assets
=
forms
.
ModelMultipleChoiceField
(
queryset
=
Asset
.
objects
.
all
(),
label
=
_
(
'Asset'
),
required
=
False
,
widget
=
forms
.
SelectMultiple
(
attrs
=
{
'class'
:
'select2'
,
'data-placeholder'
:
_
(
'Select assets'
)})
)
assets
=
forms
.
ModelMultipleChoiceField
(
queryset
=
Asset
.
objects
.
all
(),
label
=
_
(
'Asset'
),
required
=
False
,
widget
=
forms
.
SelectMultiple
(
attrs
=
{
'class'
:
'select2'
,
'data-placeholder'
:
_
(
'Select assets'
)})
)
def
__init__
(
self
,
*
args
,
**
kwargs
):
if
kwargs
.
get
(
'instance'
):
...
...
@@ -249,7 +245,7 @@ class SystemUserForm(forms.ModelForm):
key_string
=
self
.
cleaned_data
[
'private_key_file'
]
.
read
()
self
.
cleaned_data
[
'private_key_file'
]
.
seek
(
0
)
if
not
validate_ssh_private_key
(
key_string
):
raise
forms
.
ValidationError
(
_
(
'
Private key invalid
'
))
raise
forms
.
ValidationError
(
_
(
'
Invalid private key
'
))
return
self
.
cleaned_data
[
'private_key_file'
]
def
clean_password
(
self
):
...
...
apps/assets/models/asset.py
View file @
c11374ae
...
...
@@ -76,12 +76,12 @@ class Asset(models.Model):
platform
=
models
.
CharField
(
max_length
=
128
,
null
=
True
,
blank
=
True
,
verbose_name
=
'Platform'
)
os
=
models
.
CharField
(
max_length
=
128
,
null
=
True
,
blank
=
True
,
verbose_name
=
_
(
'OS'
))
os_version
=
models
.
CharField
(
max_length
=
16
,
null
=
True
,
blank
=
True
,
verbose_name
=
_
(
'OS
V
ersion'
))
os_arch
=
models
.
CharField
(
max_length
=
16
,
blank
=
True
,
null
=
True
,
verbose_name
=
_
(
'OS
A
rch'
))
os_version
=
models
.
CharField
(
max_length
=
16
,
null
=
True
,
blank
=
True
,
verbose_name
=
_
(
'OS
v
ersion'
))
os_arch
=
models
.
CharField
(
max_length
=
16
,
blank
=
True
,
null
=
True
,
verbose_name
=
_
(
'OS
a
rch'
))
hostname_raw
=
models
.
CharField
(
max_length
=
128
,
blank
=
True
,
null
=
True
,
verbose_name
=
_
(
'Hostname raw'
))
created_by
=
models
.
CharField
(
max_length
=
32
,
null
=
True
,
blank
=
True
,
verbose_name
=
_
(
'Created by'
))
date_created
=
models
.
DateTimeField
(
auto_now_add
=
True
,
null
=
True
,
blank
=
True
,
verbose_name
=
_
(
'Date
add
ed'
))
date_created
=
models
.
DateTimeField
(
auto_now_add
=
True
,
null
=
True
,
blank
=
True
,
verbose_name
=
_
(
'Date
creat
ed'
))
comment
=
models
.
TextField
(
max_length
=
128
,
default
=
''
,
blank
=
True
,
verbose_name
=
_
(
'Comment'
))
def
__unicode__
(
self
):
...
...
apps/assets/models/group.py
View file @
c11374ae
...
...
@@ -18,7 +18,7 @@ class AssetGroup(models.Model):
name
=
models
.
CharField
(
max_length
=
64
,
unique
=
True
,
verbose_name
=
_
(
'Name'
))
system_users
=
models
.
ManyToManyField
(
SystemUser
,
related_name
=
'asset_groups'
,
blank
=
True
)
created_by
=
models
.
CharField
(
max_length
=
32
,
blank
=
True
,
verbose_name
=
_
(
'Created by'
))
date_created
=
models
.
DateTimeField
(
auto_now_add
=
True
,
null
=
True
,
verbose_name
=
_
(
'Date
add
ed'
))
date_created
=
models
.
DateTimeField
(
auto_now_add
=
True
,
null
=
True
,
verbose_name
=
_
(
'Date
creat
ed'
))
comment
=
models
.
TextField
(
blank
=
True
,
verbose_name
=
_
(
'Comment'
))
def
__unicode__
(
self
):
...
...
apps/assets/models/idc.py
View file @
c11374ae
...
...
@@ -27,7 +27,7 @@ class IDC(models.Model):
intranet
=
models
.
TextField
(
blank
=
True
,
verbose_name
=
_
(
'Intranet'
))
extranet
=
models
.
TextField
(
blank
=
True
,
verbose_name
=
_
(
'Extranet'
))
date_created
=
models
.
DateTimeField
(
auto_now_add
=
True
,
null
=
True
,
verbose_name
=
_
(
'Date
add
ed'
))
auto_now_add
=
True
,
null
=
True
,
verbose_name
=
_
(
'Date
creat
ed'
))
operator
=
models
.
CharField
(
max_length
=
32
,
blank
=
True
,
verbose_name
=
_
(
'Operator'
))
created_by
=
models
.
CharField
(
...
...
apps/assets/templates/assets/_asset_bulk_update_modal.html
View file @
c11374ae
...
...
@@ -17,7 +17,7 @@
</div>
<form
method=
"post"
class=
"form-horizontal"
action=
""
id=
"fm_asset_bulk_update"
>
<div
class=
"form-group"
>
<label
class=
"control-label col-sm-2 col-lg-2 "
for=
"id_type"
>
{% trans "
System T
ype" %}
</label>
<label
class=
"control-label col-sm-2 col-lg-2 "
for=
"id_type"
>
{% trans "
Asset t
ype" %}
</label>
<div
class=
" col-sm-9 col-lg-9 "
>
<select
class=
" select2 form-control"
id=
"id_type"
name=
"type"
>
<option
value=
""
>
---------
</option>
...
...
@@ -34,7 +34,7 @@
<div
class=
"form-group"
>
<label
for=
"groups"
class=
"col-sm-2 control-label"
>
{% trans 'Asset Groups' %}
</label>
<div
class=
"col-sm-9"
id=
"select2-container"
>
<select
name=
"groups"
id=
"select2_groups"
data-placeholder=
"{% trans 'Select
Group
' %}"
class=
"select2 form-control m-b"
multiple
>
<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 %}
...
...
@@ -43,9 +43,9 @@
</div>
<div
class=
"form-group"
>
<label
for=
"users"
class=
"col-sm-2 control-label"
>
{% trans 'System
U
sers' %}
</label>
<label
for=
"users"
class=
"col-sm-2 control-label"
>
{% trans 'System
u
sers' %}
</label>
<div
class=
"col-sm-9"
id=
"select2-container"
>
<select
name=
"system_users"
id=
"select2_users"
data-placeholder=
"{% trans 'Select
System U
sers' %}"
class=
"select2 form-control m-b"
multiple
>
<select
name=
"system_users"
id=
"select2_users"
data-placeholder=
"{% trans 'Select
system u
sers' %}"
class=
"select2 form-control m-b"
multiple
>
{% for system_user in system_users %}
<option
value=
"{{ system_user.id }}"
>
{{ system_user.name }}
</option>
{% endfor %}
...
...
apps/assets/templates/assets/_asset_group_bulk_update_modal.html
View file @
c11374ae
...
...
@@ -19,7 +19,7 @@
</div>
</div>
<div
class=
"form-group"
>
<label
for=
"system_users"
class=
"col-sm-2 control-label"
>
{% trans 'System
U
sers' %}
</label>
<label
for=
"system_users"
class=
"col-sm-2 control-label"
>
{% trans 'System
u
sers' %}
</label>
<div
class=
"col-sm-9"
id=
"select2-container"
>
<select
name=
"system_users"
id=
"select2_groups"
data-placeholder=
"{% trans 'Select System Users' %}"
class=
"select2 form-control m-b"
multiple
>
{% for system_user in system_users %}
...
...
apps/assets/templates/assets/asset_detail.html
View file @
c11374ae
...
...
@@ -85,11 +85,11 @@
<td><b>
{{ asset.idc.name }}
</b></td>
</tr>
<tr>
<td>
{% trans 'Cabinet n
o
' %}:
</td>
<td>
{% trans 'Cabinet n
umber
' %}:
</td>
<td><b>
{{ asset.cabinet_no }}
</b></td>
</tr>
<tr>
<td>
{% trans 'Cabinet pos' %}:
</td>
<td>
{% trans 'Cabinet pos
ition
' %}:
</td>
<td><b>
{{ asset.cabinet_pos }}
</b></td>
</tr>
<tr>
...
...
@@ -185,7 +185,7 @@
</span></td>
</tr>
<tr>
<td>
{% trans 'R
r
efresh hardware' %}:
</td>
<td>
{% trans 'Refresh hardware' %}:
</td>
<td>
<span
class=
"pull-right"
>
<button
type=
"button"
class=
"btn btn-primary btn-xs"
id=
"btn_refresh_asset"
style=
"width: 54px"
>
{% trans 'Refresh' %}
</button>
...
...
@@ -224,7 +224,7 @@
</tr>
<tr>
<td
colspan=
"2"
class=
"no-borders"
>
<button
type=
"button"
class=
"btn btn-info btn-sm"
id=
"btn_add_user_group"
>
{% trans '
Join
' %}
</button>
<button
type=
"button"
class=
"btn btn-info btn-sm"
id=
"btn_add_user_group"
>
{% trans '
Confirm
' %}
</button>
</td>
</tr>
</form>
...
...
@@ -251,7 +251,7 @@
<form>
<tr
class=
"no-borders-tr"
>
<td
colspan=
"2"
>
<select
data-placeholder=
"{% trans 'Select system user' %}"
class=
"select2"
style=
"width: 100%"
multiple=
""
tabindex=
"4"
>
<select
data-placeholder=
"{% trans 'Select system user
s
' %}"
class=
"select2"
style=
"width: 100%"
multiple=
""
tabindex=
"4"
>
{% for system_user in system_users_remain %}
<option
value=
"{{ system_user.id }}"
id=
"opt_{{ system_user.id }}"
>
{{ system_user.name }}
</option>
{% endfor %}
...
...
@@ -260,7 +260,7 @@
</tr>
<tr
class=
"no-borders-tr"
>
<td
colspan=
"2"
>
<button
type=
"button"
class=
"btn btn-warning btn-sm btn-system-user"
>
{% trans '
Associate
' %}
</button>
<button
type=
"button"
class=
"btn btn-warning btn-sm btn-system-user"
>
{% trans '
Confirm
' %}
</button>
</td>
</tr>
</form>
...
...
@@ -371,7 +371,7 @@ $(document).ready(function () {
var
body
=
{
'is_active'
:
checked
};
var
success
=
'{% trans "Update
S
uccessfully!" %}'
;
var
success
=
'{% trans "Update
s
uccessfully!" %}'
;
var
status
=
$
(
".ibox-content > table > tbody > tr:nth-child(13) > td:last >b"
).
text
();
APIUpdateAttr
({
url
:
the_url
,
...
...
apps/assets/templates/assets/asset_group_list.html
View file @
c11374ae
...
...
@@ -101,12 +101,12 @@ $(document).ready(function(){
closeOnConfirm
:
false
},
function
()
{
var
success
=
function
()
{
var
msg
=
"{% trans 'Group
Deleted.
' %}"
;
var
msg
=
"{% trans 'Group
deleted
' %}"
;
swal
(
"{% trans 'Group Delete' %}"
,
msg
,
"success"
);
$
(
'#asset_groups_list_table'
).
DataTable
().
ajax
.
reload
();
};
var
fail
=
function
()
{
var
msg
=
"{% trans 'Group
D
eleting failed.' %}"
;
var
msg
=
"{% trans 'Group
d
eleting failed.' %}"
;
swal
(
"{% trans 'Group Delete' %}"
,
msg
,
"error"
);
};
var
url_delete
=
the_url
+
'?id__in='
+
JSON
.
stringify
(
plain_id_list
);
...
...
apps/assets/templates/assets/idc_assets.html
View file @
c11374ae
...
...
@@ -81,7 +81,7 @@
<div
class=
"col-sm-5"
style=
"padding-left: 0;padding-right: 0"
>
<div
class=
"panel panel-primary"
>
<div
class=
"panel-heading"
>
<i
class=
"fa fa-info-circle"
></i>
{% trans 'A
ttach assets to IDC ' %
}
<i
class=
"fa fa-info-circle"
></i>
{% trans 'A
dd assets to' %} {{ idc.name }
}
</div>
<div
class=
"panel-body"
>
<table
class=
"table"
>
...
...
@@ -98,7 +98,7 @@
</tr>
<tr
class=
"no-borders-tr"
>
<td
colspan=
"2"
>
<button
type=
"button"
class=
"btn btn-primary btn-sm btn-asset-attach"
>
{% trans '
Attach Assets
' %}
</button>
<button
type=
"button"
class=
"btn btn-primary btn-sm btn-asset-attach"
>
{% trans '
Confirm
' %}
</button>
</td>
</tr>
</form>
...
...
apps/assets/templates/assets/idc_list.html
View file @
c11374ae
...
...
@@ -92,7 +92,7 @@ $(document).ready(function(){
function
doDelete
()
{
swal
({
title
:
"{% trans 'Are you sure?' %}"
,
text
:
"{% trans 'This will delete the selected idc
!!!
' %}"
,
text
:
"{% trans 'This will delete the selected idc' %}"
,
type
:
"warning"
,
showCancelButton
:
true
,
confirmButtonColor
:
"#DD6B55"
,
...
...
apps/assets/templates/assets/system_user_asset.html
View file @
c11374ae
...
...
@@ -17,7 +17,7 @@
<a
href=
"{% url 'assets:system-user-detail' pk=system_user.id %}"
class=
"text-center"
><i
class=
"fa fa-laptop"
></i>
{% trans 'Detail' %}
</a>
</li>
<li
class=
"active"
><a
href=
"{% url 'assets:system-user-asset' pk=system_user.id %}"
class=
"text-center"
>
<i
class=
"fa fa-bar-chart-o"
></i>
{% trans 'A
ssociate assets and asset group
s' %}
</a>
<i
class=
"fa fa-bar-chart-o"
></i>
{% trans 'A
ttached asset
s' %}
</a>
</li>
</ul>
</div>
...
...
@@ -25,7 +25,7 @@
<div
class=
"col-sm-7"
style=
"padding-left: 0;"
>
<div
class=
"ibox float-e-margins"
>
<div
class=
"ibox-title"
>
<span
style=
"float: left"
>
{% trans 'Assets
attached
of ' %}
<b>
{{ system_user.name }}
</b><span
class=
"badge"
>
{{ paginator.count }}
</span></span>
<span
style=
"float: left"
>
{% trans 'Assets of ' %}
<b>
{{ system_user.name }}
</b><span
class=
"badge"
>
{{ paginator.count }}
</span></span>
<div
class=
"ibox-tools"
>
<a
class=
"collapse-link"
>
<i
class=
"fa fa-chevron-up"
></i>
...
...
@@ -52,19 +52,19 @@
</tr>
</thead>
<tbody>
{# {% for asset in page_obj %}#
}
{#
<tr>
#}
{#
<td>
{{ asset.hostname }}
</td>
#}
{#
<td>
{{ asset.ip }}
</td>
#}
{#
<td>
{{ asset.port }}
</td>
#}
{#
<td>
#}
{#
<i
class=
"fa fa-check text-navy"
></i>
#}
{#
</td>
#}
{#
<td>
#}
{#
<button
class=
"btn btn-danger pull-right btn-xs {% if asset.is_inherit_from_asset_groups %} disabled {% endif %}"
type=
"button"
><i
class=
"fa fa-minus"
></i></button>
#}
{#
</td>
#}
{#
</tr>
#}
{# {% endfor %}#
}
{% for asset in page_obj %
}
<tr>
<td>
{{ asset.hostname }}
</td>
<td>
{{ asset.ip }}
</td>
<td>
{{ asset.port }}
</td>
<td>
<i
class=
"fa fa-check text-navy"
></i>
</td>
<td>
<button
class=
"btn btn-danger pull-right btn-xs {% if asset.is_inherit_from_asset_groups %} disabled {% endif %}"
type=
"button"
><i
class=
"fa fa-minus"
></i></button>
</td>
</tr>
{% endfor %
}
</tbody>
</table>
{#
<div
class=
"row"
>
#}
...
...
@@ -93,7 +93,7 @@
</tr>
<tr
class=
"no-borders-tr"
>
<td
colspan=
"2"
>
<button
type=
"button"
class=
"btn btn-primary btn-sm btn-add-asset2system-user"
>
{% trans '
Attach Asset
' %}
</button>
<button
type=
"button"
class=
"btn btn-primary btn-sm btn-add-asset2system-user"
>
{% trans '
Confirm
' %}
</button>
</td>
</tr>
</form>
...
...
apps/assets/templates/assets/system_user_asset_group.html
deleted
100644 → 0
View file @
92ebe85a
{% extends 'base.html' %}
{% load static %}
{% load i18n %}
{% block custom_head_css_js %}
<link
href=
"{% static "
css
/
plugins
/
select2
/
select2
.
min
.
css
"
%}"
rel=
"stylesheet"
>
<script
src=
"{% static "
js
/
plugins
/
select2
/
select2
.
full
.
min
.
js
"
%}"
></script>
{% endblock %}
{% block content %}
<div
class=
"wrapper wrapper-content animated fadeInRight"
>
<div
class=
"row"
>
<div
class=
"col-sm-12"
>
<div
class=
"ibox float-e-margins"
>
<div
class=
"panel-options"
>
<ul
class=
"nav nav-tabs"
>
<li>
<a
href=
"{% url 'assets:system-user-detail' pk=system_user.id %}"
class=
"text-center"
><i
class=
"fa fa-laptop"
></i>
{% trans 'Detail' %}
</a>
</li>
<li><a
href=
"{% url 'assets:system-user-asset' pk=system_user.id %}"
class=
"text-center"
>
<i
class=
"fa fa-bar-chart-o"
></i>
{% trans 'Associate assets' %}
</a>
</li>
<li
class=
"active"
>
<a
href=
"{% url 'assets:system-user-asset-group' pk=system_user.id %}"
class=
"text-center"
>
<i
class=
"fa fa-bar-chart-o"
></i>
{% trans 'Associate asset groups' %}
</a>
</li>
</ul>
</div>
<div
class=
"tab-content"
>
<div
class=
"col-sm-7"
style=
"padding-left: 0;"
>
<div
class=
"ibox float-e-margins"
>
<div
class=
"ibox-title"
>
<span
style=
"float: left"
>
{% trans 'Asset list of ' %}
<b>
{{ admin_user.name }}
</b></span>
<div
class=
"ibox-tools"
>
<a
class=
"collapse-link"
>
<i
class=
"fa fa-chevron-up"
></i>
</a>
<a
class=
"dropdown-toggle"
data-toggle=
"dropdown"
href=
"#"
>
<i
class=
"fa fa-wrench"
></i>
</a>
<ul
class=
"dropdown-menu dropdown-user"
>
</ul>
<a
class=
"close-link"
>
<i
class=
"fa fa-times"
></i>
</a>
</div>
</div>
<div
class=
"ibox-content"
>
<table
class=
"table table-hover"
>
<thead>
<tr>
<th>
{% trans 'Name' %}
</th>
<th>
{% trans 'Asset num' %}
</th>
<th>
{% trans 'Unavailable num' %}
</th>
<th>
{% trans 'Comment' %}
</th>
</tr>
</thead>
<tbody>
{% for asset_group in page_obj %}
<tr>
<td>
{{ asset_group.name }}
</td>
<td>
{{ asset_group_group.assets.count }}
</td>
<td>
{{ asset_group_group.assets.count }}
</td>
<td>
{{ asset_group.comment|truncatewords:4 }}
</td>
</tr>
{% endfor %}
</tbody>
</table>
<div
class=
"row"
>
{% include '_pagination.html' %}
</div>
</div>
</div>
</div>
<div
class=
"col-sm-5"
style=
"padding-left: 0;padding-right: 0"
>
<div
class=
"panel panel-primary"
>
<div
class=
"panel-heading"
>
<i
class=
"fa fa-info-circle"
></i>
{% trans 'Add asset group to this system user' %}
</div>
<div
class=
"panel-body"
>
<table
class=
"table"
>
<tbody>
<form>
<tr
class=
"no-borders-tr"
>
<td
colspan=
"2"
>
<select
data-placeholder=
"{% trans 'Select asset group' %}"
class=
"select2"
style=
"width: 100%"
multiple=
""
tabindex=
"4"
>
{% for asset_group in asset_groups %}
<option
value=
"{{ asset_group.id }}"
>
{{ asset_group.name}}
</option>
{% endfor %}
</select>
</td>
</tr>
<tr
class=
"no-borders-tr"
>
<td
colspan=
"2"
>
<button
type=
"button"
class=
"btn btn-primary btn-sm"
>
{% trans 'Add' %}
</button>
</td>
</tr>
</form>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
{% endblock %}
{% block custom_foot_js %}
<script>
{
#
function
switch_user_status
(
obj
)
{
#
}
{
#
var
status
=
$
(
obj
).
prop
(
'checked'
);
#
}
{
##
}
{
#
$
.
ajax
({
#
}
{
#
url
:
"{% url 'users:user-active-api' pk=user.id %}"
,
#
}
{
#
type
:
"PUT"
,
#
}
{
#
data
:
{
#
}
{
#
'is_active'
:
status
#
}
{
#
},
#
}
{
#
success
:
function
(
data
,
status
)
{
#
}
{
#
console
.
log
(
data
)
#
}
{
#
},
#
}
{
#
error
:
function
()
{
#
}
{
#
console
.
log
(
'error'
)
#
}
{
#
}
#
}
{
#
})
#
}
{
#
}
#
}
$
(
document
).
ready
(
function
()
{
$
(
'.select2'
).
select2
();
});
</script>
{% endblock %}
apps/assets/templates/assets/system_user_detail.html
View file @
c11374ae
...
...
@@ -18,7 +18,7 @@
</li>
<li>
<a
href=
"{% url 'assets:system-user-asset' pk=system_user.id %}"
class=
"text-center"
>
<i
class=
"fa fa-bar-chart-o"
></i>
{% trans 'A
ssociate assets and asset group
s' %}
<i
class=
"fa fa-bar-chart-o"
></i>
{% trans 'A
ttached asset
s' %}
</a>
</li>
<li
class=
"pull-right"
>
...
...
@@ -62,15 +62,7 @@
</tr>
<tr>
<td>
{% trans 'Auto push' %}:
</td>
<td><b>
{{ system_user.protocol }}
</b></td>
</tr>
<tr>
<td>
{% trans 'Auto update' %}:
</td>
<td><b>
{{ system_user.auto_update }}
</b></td>
</tr>
<tr>
<td>
{% trans 'As default' %}:
</td>
<td><b>
{{ system_user.protocol }}
</b></td>
<td><b>
{{ system_user.auto_push|yesno:"Yes,No,Unknown" }}
</b></td>
</tr>
<tr>
<td>
{% trans 'Sudo' %}:
</td>
...
...
@@ -121,7 +113,7 @@
<table
class=
"table"
>
<tbody>
<tr
class=
"no-borders-tr"
>
<td
width=
"50%"
>
{% trans 'Get man
n
ual install script' %}:
</td>
<td
width=
"50%"
>
{% trans 'Get manual install script' %}:
</td>
<td>
<span
style=
"float: right"
>
<button
type=
"button"
class=
"btn btn-primary btn-xs"
style=
"width: 54px"
>
{% trans 'Get' %}
</button>
...
...
apps/assets/views/admin_user.py
View file @
c11374ae
...
...
@@ -49,10 +49,10 @@ class AdminUserCreateView(AdminUserRequiredMixin,
def
get_success_message
(
self
,
cleaned_data
):
success_message
=
_
(
'Create admin user <a href="
%
s">
%
s</a> successfully.'
%
(
reverse_lazy
(
'assets:admin-user-detail'
,
kwargs
=
{
'pk'
:
self
.
object
.
pk
}),
self
.
object
.
name
,
'Create admin user <a href="
{url}">{name}</a> successfully.'
.
format
(
url
=
reverse_lazy
(
'assets:admin-user-detail'
,
kwargs
=
{
'pk'
:
self
.
object
.
pk
}),
name
=
self
.
object
.
name
,
))
return
success_message
...
...
apps/assets/views/system_user.py
View file @
c11374ae
...
...
@@ -50,16 +50,13 @@ class SystemUserCreateView(AdminUserRequiredMixin, SuccessMessageMixin, CreateVi
kwargs
.
update
(
context
)
return
super
(
SystemUserCreateView
,
self
)
.
get_context_data
(
**
kwargs
)
def
form_invalid
(
self
,
form
):
print
(
form
.
errors
)
return
super
(
SystemUserCreateView
,
self
)
.
form_invalid
(
form
)
def
get_success_message
(
self
,
cleaned_data
):
success_message
=
_
(
'Create system user <a href="
%
s">
%
s</a> successfully.'
%
(
reverse_lazy
(
'assets:system-user-detail'
,
kwargs
=
{
'pk'
:
self
.
object
.
pk
}),
self
.
object
.
name
,
))
url
=
reverse_lazy
(
'assets:system-user-detail'
,
kwargs
=
{
'pk'
:
self
.
object
.
pk
}),
success_message
=
_
(
'Create system user <a href="{url}">{name}</a> '
'successfully.'
.
format
(
url
=
url
,
name
=
self
.
object
.
name
)
)
return
success_message
...
...
@@ -78,7 +75,8 @@ class SystemUserUpdateView(AdminUserRequiredMixin, UpdateView):
return
super
(
SystemUserUpdateView
,
self
)
.
get_context_data
(
**
kwargs
)
def
get_success_url
(
self
):
success_url
=
reverse_lazy
(
'assets:system-user-detail'
,
kwargs
=
{
'pk'
:
self
.
object
.
pk
})
success_url
=
reverse_lazy
(
'assets:system-user-detail'
,
kwargs
=
{
'pk'
:
self
.
object
.
pk
})
return
success_url
...
...
apps/jumpserver/settings.py
View file @
c11374ae
...
...
@@ -112,6 +112,10 @@ SESSION_COOKIE_DOMAIN = CONFIG.SESSION_COOKIE_DOMAIN or None
CSRF_COOKIE_DOMAIN
=
CONFIG
.
CSRF_COOKIE_DOMAIN
or
None
SESSION_COOKIE_AGE
=
CONFIG
.
SESSION_COOKIE_AGE
or
3600
*
24
print
(
SESSION_COOKIE_DOMAIN
,
CSRF_COOKIE_DOMAIN
)
MESSAGE_STORAGE
=
'django.contrib.messages.storage.cookie.CookieStorage'
# Database
# https://docs.djangoproject.com/en/1.10/ref/settings/#databases
...
...
@@ -327,7 +331,7 @@ CACHES = {
CAPTCHA_IMAGE_SIZE
=
(
80
,
33
)
CAPTCHA_FOREGROUND_COLOR
=
'#001100'
CAPTCHA_NOISE_FUNCTIONS
=
(
'captcha.helpers.noise_dots'
,)
CAPTCHA_TEST_MODE
=
CONFIG
.
CAPTCHA_TEST_MODE
COMMAND_STORE_BACKEND
=
'audits.backends.command.db'
RECORD_STORE_BACKEND
=
'audits.backends.record.db'
CAPTCHA_TEST_MODE
=
CONFIG
.
CAPTCHA_TEST_MODE
apps/locale/zh/LC_MESSAGES/django.po
View file @
c11374ae
This diff is collapsed.
Click to expand it.
apps/ops/models.py
View file @
c11374ae
...
...
@@ -22,7 +22,7 @@ class Task(models.Model):
timedelta
=
models
.
FloatField
(
default
=
0.0
,
verbose_name
=
_
(
'Time'
),
null
=
True
)
is_finished
=
models
.
BooleanField
(
default
=
False
,
verbose_name
=
_
(
'Is finished'
))
is_success
=
models
.
BooleanField
(
default
=
False
,
verbose_name
=
_
(
'Is success'
))
assets
=
models
.
TextField
(
blank
=
True
,
null
=
True
,
verbose_name
=
_
(
'Assets
for
id'
))
# Asset inventory may be change
assets
=
models
.
TextField
(
blank
=
True
,
null
=
True
,
verbose_name
=
_
(
'Assets id'
))
# Asset inventory may be change
_modules_args
=
models
.
TextField
(
blank
=
True
,
null
=
True
,
verbose_name
=
_
(
'Task module and args json format'
))
pattern
=
models
.
CharField
(
max_length
=
64
,
default
=
'all'
,
verbose_name
=
_
(
'Task run pattern'
))
result
=
models
.
TextField
(
blank
=
True
,
null
=
True
,
verbose_name
=
_
(
'Task raw result'
))
...
...
apps/ops/templates/ops/task_detail.html
View file @
c11374ae
...
...
@@ -81,7 +81,7 @@
{% endif %}
</tr>
<tr>
<td>
{% trans '
Assets
' %}:
</td>
<td>
{% trans '
assets
' %}:
</td>
<td>
<b>
{% for asset in object.total_assets %}
...
...
apps/perms/templates/perms/asset_permission_asset.html
View file @
c11374ae
...
...
@@ -106,7 +106,7 @@
<form>
<tr
class=
"no-borders-tr"
>
<td
colspan=
"2"
>
<select
data-placeholder=
"{% trans 'Select asset
' %}"
class=
"select2"
style=
"width: 100%"
multiple=
""
tabindex=
"4"
>
<select
data-placeholder=
"{% trans 'Select asset
s
' %}"
class=
"select2"
style=
"width: 100%"
multiple=
""
tabindex=
"4"
>
{% for asset in asset_remain %}
<option
value=
"{{ asset.id }}"
>
{{ asset.hostname }}: {{ asset.ip }}
</option>
{% endfor %}
...
...
apps/perms/views.py
View file @
c11374ae
...
...
@@ -80,11 +80,11 @@ class AssetPermissionCreateView(AdminUserRequiredMixin,
return
super
(
AssetPermissionCreateView
,
self
)
.
get_context_data
(
**
kwargs
)
def
get_success_message
(
self
,
cleaned_data
):
url
=
reverse_lazy
(
'perms:asset-permission-detail'
,
kwargs
=
{
'pk'
:
self
.
object
.
pk
})
success_message
=
_
(
'Create asset permission <a href="
%
s">
%
s </a> '
'successfully.'
%
(
reverse_lazy
(
'perms:asset-permission-detail'
,
kwargs
=
{
'pk'
:
self
.
object
.
pk
}),
self
.
object
.
name
,))
'Create asset permission <a href="{url}"> {name} </a> '
'successfully.'
.
format
(
url
=
url
,
name
=
self
.
object
.
name
))
return
success_message
def
form_valid
(
self
,
form
):
...
...
@@ -102,8 +102,9 @@ class AssetPermissionUpdateView(AdminUserRequiredMixin, UpdateView):
model
=
AssetPermission
form_class
=
AssetPermissionForm
template_name
=
'perms/asset_permission_create_update.html'
success_message
=
_
(
'Update asset permission '
'<a href="
%
s">
%
s </a> successfully.'
)
success_message
=
_
(
'Update asset permission <a href="{url}"> {name} </a> successfully.'
)
def
get_context_data
(
self
,
**
kwargs
):
context
=
{
...
...
@@ -113,10 +114,12 @@ class AssetPermissionUpdateView(AdminUserRequiredMixin, UpdateView):
kwargs
.
update
(
context
)
return
super
(
AssetPermissionUpdateView
,
self
)
.
get_context_data
(
**
kwargs
)
def
get_success_url
(
self
):
success_url
=
reverse_lazy
(
'perms:asset-permission-detail'
,
kwargs
=
{
'pk'
:
self
.
object
.
pk
})
return
success_url
def
get_success_message
(
self
):
url
=
reverse_lazy
(
'perms:asset-permission-detail'
,
kwargs
=
{
'pk'
:
self
.
object
.
pk
})
return
self
.
success_message
.
format
(
url
=
url
,
name
=
self
.
object
.
name
)
def
form_valid
(
self
,
form
):
assets
=
form
.
cleaned_data
[
'assets'
]
...
...
apps/templates/_base_list.html
View file @
c11374ae
{% extends 'base.html' %}
{% load static %}
{% 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"
>
...
...
@@ -40,17 +41,17 @@
<div
class=
"input-group"
>
<div
class=
"input-group-btn"
>
<button
id=
'search_btn'
type=
"submit"
class=
"btn btn-sm btn-primary"
>
搜索
{% trans 'Search' %}
</button>
</div>
</div>
{% endblock %}
</form>
{% endblock %}
{% block tags_list %}{% endblock %
}
{# {% block tags_list %}{% endblock %}#
}
</div>
{% block table_container %}
<table
class=
"table table-striped table-bordered table-hover
"
id=
"editable"
>
<table
class=
"table table-striped table-bordered table-hover"
id=
"editable"
>
<thead>
<tr>
{% block table_head %} {% endblock %}
...
...
apps/templates/_nav.html
View file @
c11374ae
{% load i18n %}
<li
id=
"index"
>
<a
href=
"{% url 'index' %}"
>
<i
class=
"fa fa-dashboard"
></i>
<span
class=
"nav-label"
>
{% trans '
Home
' %}
</span><span
class=
"label label-info pull-right"
></span>
<i
class=
"fa fa-dashboard"
></i>
<span
class=
"nav-label"
>
{% trans '
Dashboard
' %}
</span><span
class=
"label label-info pull-right"
></span>
</a>
</li>
<li
id=
"users"
>
...
...
apps/templates/base.html
View file @
c11374ae
...
...
@@ -16,7 +16,6 @@
<body>
<div
id=
"wrapper"
>
{% include '_left_side_bar.html' %}
<div
id=
"page-wrapper"
class=
"gray-bg"
>
{% include '_header_bar.html' %}
...
...
apps/users/forms.py
View file @
c11374ae
...
...
@@ -131,14 +131,6 @@ class UserGroupForm(forms.ModelForm):
}
# class UserInfoForm(forms.Form):
# name = forms.CharField(max_length=20, label=_('name'))
# avatar = forms.ImageField(label=_('avatar'), required=False)
# wechat = forms.CharField(max_length=30, label=_('wechat'), required=False)
# phone = forms.CharField(max_length=20, label=_('phone'), required=False)
# enable_otp = forms.BooleanField(required=False, label=_('enable otp'))
class
UserPrivateAssetPermissionForm
(
forms
.
ModelForm
):
def
save
(
self
,
commit
=
True
):
self
.
instance
=
super
(
UserPrivateAssetPermissionForm
,
self
)
\
...
...
apps/users/models/group.py
View file @
c11374ae
...
...
@@ -17,7 +17,8 @@ __all__ = ['UserGroup']
class
UserGroup
(
NoDeleteModelMixin
):
name
=
models
.
CharField
(
max_length
=
128
,
verbose_name
=
_
(
'Name'
))
comment
=
models
.
TextField
(
blank
=
True
,
verbose_name
=
_
(
'Comment'
))
date_created
=
models
.
DateTimeField
(
auto_now_add
=
True
,
null
=
True
)
date_created
=
models
.
DateTimeField
(
auto_now_add
=
True
,
null
=
True
,
verbose_name
=
_
(
'Date created'
))
created_by
=
models
.
CharField
(
max_length
=
100
)
def
__unicode__
(
self
):
...
...
apps/users/templates/users/_user_bulk_update_modal.html
View file @
c11374ae
...
...
@@ -18,7 +18,7 @@
<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
Group
' %}"
class=
"select2 form-control m-b"
multiple
>
<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 %}
...
...
apps/users/templates/users/user_detail.html
View file @
c11374ae
...
...
@@ -268,7 +268,7 @@ $(document).ready(function() {
var
body
=
{
'is_active'
:
checked
};
var
success
=
'{% trans "Update
S
uccessfully!" %}'
;
var
success
=
'{% trans "Update
s
uccessfully!" %}'
;
APIUpdateAttr
({
url
:
the_url
,
body
:
JSON
.
stringify
(
body
),
...
...
@@ -281,7 +281,7 @@ $(document).ready(function() {
var
body
=
{
'enable_otp'
:
checked
};
var
success
=
'{% trans "Update
S
uccessfully!" %}'
;
var
success
=
'{% trans "Update
s
uccessfully!" %}'
;
APIUpdateAttr
({
url
:
the_url
,
body
:
JSON
.
stringify
(
body
),
...
...
@@ -320,7 +320,7 @@ $(document).ready(function() {
var
body
=
{};
var
success
=
function
()
{
var
msg
=
"{% trans "
An
e
-
mail
has
been
sent
to
the
user
\
's mailbox." %}";
swal("{% trans '
Password
-
Reset
' %}", msg, "success");
swal("{% trans '
Reset
password
' %}", msg, "success");
};
APIUpdateAttr({
url: the_url,
...
...
@@ -330,7 +330,7 @@ $(document).ready(function() {
}
swal({
title: "{% trans '
Are
you
sure
?
' %}",
text: "{% trans
'
This
will
reset
the
user
\
's password. A password-reset email will be sent to the user
\'
s mailbox.'
%
}
",
text: "{% trans
"This will reset the user'
s
password
.
A
password
-
reset
email
will
be
sent
to
the
user
\
's mailbox."
%}",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
...
...
@@ -345,7 +345,7 @@ $(document).ready(function() {
var body = {};
var success = function() {
var msg = "{% trans '
The
reset
-
ssh
-
public
-
key
E
-
mail
has
been
sent
successfully
.
Please
inform
the
user
to
update
his
new
ssh
public
key
.
' %}";
swal("
{
%
trans
'
SSH-Public-Key Reset
'
%
}
", msg, "
success
");
swal("{% trans '
Reset
SSH
public
key
' %}", msg, "success");
};
APIUpdateAttr({
url: the_url,
...
...
apps/users/templates/users/user_group_create_update.html
View file @
c11374ae
...
...
@@ -42,7 +42,7 @@
<div
class=
"form-group"
>
<div
class=
"col-sm-4 col-sm-offset-2"
>
<button
class=
"btn btn-white"
type=
"reset"
>
{% trans 'Cancel' %}
</button>
<button
id=
"submit_button"
class=
"btn btn-primary"
type=
"submit"
>
{% trans '
c
onfirm' %}
</button>
<button
id=
"submit_button"
class=
"btn btn-primary"
type=
"submit"
>
{% trans '
C
onfirm' %}
</button>
</div>
</div>
</form>
...
...
apps/users/templates/users/user_group_detail.html
View file @
c11374ae
...
...
@@ -19,7 +19,7 @@
<div
class=
"panel-options"
>
<ul
class=
"nav nav-tabs"
>
<li
class=
"active"
>
<a
href=
"{% url 'users:user-group-detail' pk=user_group.id %}"
class=
"text-center"
><i
class=
"fa fa-laptop"
></i>
{% trans 'User
Group D
etail' %}
</a>
<a
href=
"{% url 'users:user-group-detail' pk=user_group.id %}"
class=
"text-center"
><i
class=
"fa fa-laptop"
></i>
{% trans 'User
group d
etail' %}
</a>
</li>
<li>
<a
href=
"{% url 'users:user-group-asset-permission' pk=user_group.id %}"
class=
"text-center"
><i
class=
"fa fa-bar-chart-o"
></i>
{% trans 'Asset permission' %}
</a>
...
...
apps/users/templates/users/user_group_list.html
View file @
c11374ae
...
...
@@ -2,7 +2,7 @@
{% load i18n static %}
{% block table_search %}{% endblock %}
{% block table_container %}
<div
class=
"pull-left m-r-5"
><a
href=
"{% url 'users:user-group-create' %}"
class=
"btn btn-sm btn-primary "
>
{% trans "
Add User G
roup" %}
</a></div>
<div
class=
"pull-left m-r-5"
><a
href=
"{% url 'users:user-group-create' %}"
class=
"btn btn-sm btn-primary "
>
{% trans "
Create user g
roup" %}
</a></div>
<table
class=
"table table-striped table-bordered table-hover "
id=
"group_list_table"
>
<thead>
<tr>
...
...
@@ -10,7 +10,7 @@
<input
id=
""
type=
"checkbox"
class=
"ipt_check_all"
>
</th>
<th
class=
"text-center"
>
{% trans 'Name' %}
</th>
<th
class=
"text-center"
>
{% trans 'User
Am
ount' %}
</th>
<th
class=
"text-center"
>
{% trans 'User
c
ount' %}
</th>
<th
class=
"text-center"
>
{% trans 'Comment' %}
</th>
<th
class=
"text-center"
>
{% trans 'Action' %}
</th>
</tr>
...
...
@@ -61,6 +61,7 @@ $(document).ready(function() {
ajax_url
:
'{% url "api-users:user-group-list" %}'
,
columns
:
[{
data
:
function
(){
return
""
}},
{
data
:
"name"
},
{
data
:
"user_amount"
},
{
data
:
"comment"
},
{
data
:
"id"
}],
order
:
[
4
,
'asc'
],
op_html
:
$
(
'#actions'
).
html
()
};
jumpserver
.
initDataTable
(
options
);
...
...
apps/users/templates/users/user_profile.html
View file @
c11374ae
...
...
@@ -141,7 +141,7 @@
</td>
</tr>
<tr>
<td>
{% trans 'Reset public key' %}:
</td>
<td>
{% trans 'Reset
SSH
public key' %}:
</td>
<td>
<span
class=
"pull-right"
>
<a
type=
"button"
class=
"btn btn-primary btn-xs"
style=
"width: 54px"
href=
"{% url 'users:user-pubkey-update' %}"
>
{% trans 'Reset' %}
</a>
...
...
apps/users/views/group.py
View file @
c11374ae
...
...
@@ -9,6 +9,7 @@ from django.views.generic import ListView
from
django.views.generic.base
import
TemplateView
from
django.views.generic.edit
import
CreateView
,
UpdateView
,
FormMixin
from
django.views.generic.detail
import
DetailView
,
SingleObjectMixin
from
django.contrib.messages.views
import
SuccessMessageMixin
from
common.utils
import
get_logger
from
perms.models
import
AssetPermission
...
...
@@ -31,11 +32,12 @@ class UserGroupListView(AdminUserRequiredMixin, TemplateView):
return
context
class
UserGroupCreateView
(
AdminUserRequiredMixin
,
CreateView
):
class
UserGroupCreateView
(
AdminUserRequiredMixin
,
SuccessMessageMixin
,
CreateView
):
model
=
UserGroup
form_class
=
forms
.
UserGroupForm
template_name
=
'users/user_group_create_update.html'
success_url
=
reverse_lazy
(
'users:user-group-list'
)
success_message
=
'<a href={url}> {name} </a> was created successfully'
def
get_context_data
(
self
,
**
kwargs
):
context
=
super
(
UserGroupCreateView
,
self
)
.
get_context_data
(
**
kwargs
)
...
...
@@ -54,6 +56,14 @@ class UserGroupCreateView(AdminUserRequiredMixin, CreateView):
user_group
.
save
()
return
super
(
UserGroupCreateView
,
self
)
.
form_valid
(
form
)
def
get_success_message
(
self
,
cleaned_data
):
url
=
reverse_lazy
(
'users:user-group-detail'
,
kwargs
=
{
'pk'
:
self
.
object
.
id
}
)
return
self
.
success_message
.
format
(
url
=
url
,
name
=
self
.
object
.
name
)
class
UserGroupUpdateView
(
AdminUserRequiredMixin
,
UpdateView
):
model
=
UserGroup
...
...
@@ -68,7 +78,7 @@ class UserGroupUpdateView(AdminUserRequiredMixin, UpdateView):
group_users
=
[
user
.
id
for
user
in
self
.
object
.
users
.
all
()]
context
.
update
({
'app'
:
_
(
'Users'
),
'action'
:
_
(
'Update
User G
roup'
),
'action'
:
_
(
'Update
user g
roup'
),
'users'
:
users
,
'group_users'
:
group_users
})
...
...
apps/users/views/user.py
View file @
c11374ae
...
...
@@ -63,7 +63,7 @@ class UserCreateView(AdminUserRequiredMixin, SuccessMessageMixin, CreateView):
form_class
=
forms
.
UserCreateUpdateForm
template_name
=
'users/user_create.html'
success_url
=
reverse_lazy
(
'users:user-list'
)
success_message
=
_
(
'Create user <a href="
%
s">
%
s
</a> successfully.'
)
success_message
=
_
(
'Create user <a href="
{url}">{name}
</a> successfully.'
)
def
get_context_data
(
self
,
**
kwargs
):
context
=
super
(
UserCreateView
,
self
)
.
get_context_data
(
**
kwargs
)
...
...
@@ -78,9 +78,9 @@ class UserCreateView(AdminUserRequiredMixin, SuccessMessageMixin, CreateView):
return
super
(
UserCreateView
,
self
)
.
form_valid
(
form
)
def
get_success_message
(
self
,
cleaned_data
):
return
self
.
success_message
%
(
reverse_lazy
(
'users:user-detail'
,
kwargs
=
{
'pk'
:
self
.
object
.
pk
}),
self
.
object
.
name
,
url
=
reverse_lazy
(
'users:user-detail'
,
kwargs
=
{
'pk'
:
self
.
object
.
pk
})
return
self
.
success_message
.
format
(
url
=
url
,
name
=
self
.
object
.
name
)
...
...
@@ -331,15 +331,15 @@ class UserProfileUpdateView(LoginRequiredMixin, UpdateView):
model
=
User
form_class
=
forms
.
UserProfileForm
success_url
=
reverse_lazy
(
'users:user-profile'
)
success_message
=
_
(
'Create user <a href="
%
s">
%
s
</a> successfully.'
)
success_message
=
_
(
'Create user <a href="
{url}">{name}
</a> successfully.'
)
def
get_object
(
self
,
queryset
=
None
):
return
self
.
request
.
user
def
get_success_message
(
self
,
cleaned_data
):
return
self
.
success_message
%
(
reverse_lazy
(
'users:user-detail'
,
kwargs
=
{
'pk'
:
self
.
object
.
pk
}),
self
.
object
.
name
,
url
=
reverse_lazy
(
'users:user-detail'
,
kwargs
=
{
'pk'
:
self
.
object
.
pk
})
return
self
.
success_message
.
format
(
url
=
url
,
name
=
self
.
object
.
name
)
def
get_context_data
(
self
,
**
kwargs
):
...
...
requirements/deb_requirements.txt
View file @
c11374ae
ibtiff4-dev libjpeg8-dev zlib1g-dev libfreetype6-dev liblcms2-dev libwebp-dev tcl8.5-dev tk8.5-dev python-tk
\ No newline at end of file
libtiff4-dev libjpeg8-dev zlib1g-dev libfreetype6-dev liblcms2-dev libwebp-dev tcl8.5-dev tk8.5-dev python-tk
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