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
28223421
Commit
28223421
authored
Jan 05, 2018
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Bugfix] 修复一下bug
1. 添加管理用户时同名的异常 2. 添加授权规则的检查
parent
56fd1824
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
16 deletions
+21
-16
forms.py
apps/assets/forms.py
+10
-7
asset_permission_list.html
apps/perms/templates/perms/asset_permission_list.html
+4
-2
_header_bar.html
apps/templates/_header_bar.html
+6
-6
user_list.html
apps/users/templates/users/user_list.html
+1
-1
No files found.
apps/assets/forms.py
View file @
28223421
...
...
@@ -172,9 +172,10 @@ class AdminUserForm(forms.ModelForm):
widget
=
forms
.
PasswordInput
,
max_length
=
128
,
strip
=
True
,
required
=
False
,
help_text
=
_
(
'Password or private key password'
),
label
=
_
(
"Password"
),
)
# Need use upload private key file except paste private key content
private_key_file
=
forms
.
FileField
(
required
=
False
)
private_key_file
=
forms
.
FileField
(
required
=
False
,
label
=
_
(
"Private key"
)
)
def
save
(
self
,
commit
=
True
):
# Because we define custom field, so we need rewrite :method: `save`
...
...
@@ -204,12 +205,14 @@ class AdminUserForm(forms.ModelForm):
return
private_key_file
def
clean
(
self
):
super
()
.
clean
()
password
=
self
.
cleaned_data
[
'password'
]
private_key_file
=
self
.
cleaned_data
.
get
(
'private_key_file'
,
''
)
if
not
self
.
instance
and
not
(
password
or
private_key_file
):
raise
forms
.
ValidationError
(
_
(
'Password and private key file must be input one'
))
if
not
password
and
not
private_key_file
:
raise
forms
.
ValidationError
(
_
(
'Password and private key file must be input one'
))
class
Meta
:
model
=
AdminUser
...
...
@@ -284,9 +287,9 @@ class SystemUserForm(forms.ModelForm):
help_texts
=
{
'name'
:
'* required'
,
'username'
:
'* required'
,
'cluster'
:
'If auto push checked, system user will be create at cluster assets'
,
'auto_push'
:
'Auto push system user to asset'
,
'priority'
:
'High level will be using login asset as default, if user was granted more than 2 system user'
,
'cluster'
:
_
(
'If auto push checked, system user will be create at cluster assets'
)
,
'auto_push'
:
_
(
'Auto push system user to asset'
)
,
'priority'
:
_
(
'High level will be using login asset as default, if user was granted more than 2 system user'
)
,
}
...
...
apps/perms/templates/perms/asset_permission_list.html
View file @
28223421
...
...
@@ -69,9 +69,11 @@ function initTable() {
$
(
td
).
html
(
'<i class="fa fa-check text-navy"></i>'
)
}
}},
{
targets
:
8
,
createdCell
:
function
(
td
,
cellData
)
{
{
targets
:
8
,
createdCell
:
function
(
td
,
cellData
,
rowData
)
{
var
update_btn
=
'<a href="{% url "perms:asset-permission-update" pk=DEFAULT_PK %}" class="btn btn-xs m-l-xs btn-info">{% trans "Update" %}</a>'
.
replace
(
'{{ DEFAULT_PK }}'
,
cellData
);
var
del_btn
=
'<a class="btn btn-xs btn-danger m-l-xs btn-del-permission" data-uid="{{ DEFAULT_PK }}">{% trans "Delete" %}</a>'
.
replace
(
'{{ DEFAULT_PK }}'
,
cellData
);
var
del_btn
=
'<a class="btn btn-xs btn-danger m-l-xs btn-del" data-uid="{{ DEFAULT_PK }}" data-name="99991938">{% trans "Delete" %}</a>'
.
replace
(
'{{ DEFAULT_PK }}'
,
cellData
)
.
replace
(
'99991938'
,
rowData
.
name
);
$
(
td
).
html
(
update_btn
+
del_btn
);
}}
...
...
apps/templates/_header_bar.html
View file @
28223421
...
...
@@ -19,7 +19,7 @@
</a>
</li>
<li
class=
"dropdown"
>
{% if user.is_authenticated %}
{% if
request.
user.is_authenticated %}
<a
data-toggle=
"dropdown"
class=
"dropdown-toggle"
href=
"#"
>
<span
class=
"m-r-sm text-muted welcome-message"
>
<img
alt=
"image"
class=
"img-circle"
width=
"40"
height=
"40"
src=
"{{ request.user.avatar_url }}"
/>
...
...
@@ -34,11 +34,11 @@
<li><a
href=
"{% url 'users:user-profile-update' %}"
>
{% trans 'Profile settings' %}
</a></li>
<li
class=
"divider"
></li>
{% if request.user.is_superuser %}
{% if request.COOKIES.IN_ADMIN_PAGE == 'No' %}
<li><a
id=
"switch_admin"
>
{% trans 'Admin page' %}
</a></li>
{% else %}
<li><a
id=
"switch_user"
>
{% trans 'User page' %}
</a></li>
{% endif %}
{% if request.COOKIES.IN_ADMIN_PAGE == 'No' %}
<li><a
id=
"switch_admin"
>
{% trans 'Admin page' %}
</a></li>
{% else %}
<li><a
id=
"switch_user"
>
{% trans 'User page' %}
</a></li>
{% endif %}
{% endif %}
<li><a
href=
"{% url 'users:logout' %}"
>
{% trans 'Logout' %}
</a></li>
</ul>
...
...
apps/users/templates/users/user_list.html
View file @
28223421
...
...
@@ -223,7 +223,7 @@ $(document).ready(function(){
var
$this
=
$
(
this
);
var
name
=
$this
.
data
(
'name'
);
var
uid
=
$this
.
data
(
'uid'
);
var
the_url
=
'{% url "api-users:user-detail" pk=
'
00000000
-
0000
-
0000
-
0000
-
000000000000
' %}'
.
replace
(
'00000000-0000-0000-0000-000000000000'
,
uid
);
var
the_url
=
'{% url "api-users:user-detail" pk=
"{{ DEFAULT_PK }}" %}'
.
replace
(
"{{ DEFAULT_PK }}"
,
uid
);
objectDelete
(
$this
,
name
,
the_url
);
})
</script>
...
...
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