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
67771105
Commit
67771105
authored
Nov 16, 2015
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
key目录变化
parent
71ef4b07
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
24 additions
and
70 deletions
+24
-70
user_api.py
juser/user_api.py
+1
-2
views.py
juser/views.py
+3
-55
base.js
static/js/base.js
+13
-4
group_list.html
templates/juser/group_list.html
+2
-2
user_add.html
templates/juser/user_add.html
+2
-2
user_edit.html
templates/juser/user_edit.html
+1
-1
user_list.html
templates/juser/user_list.html
+2
-2
paginator.html
templates/paginator.html
+0
-2
No files found.
juser/user_api.py
View file @
67771105
...
...
@@ -121,8 +121,7 @@ def db_del_user(username):
def
gen_ssh_key
(
username
,
password
=
''
,
key_dir
=
os
.
path
.
join
(
BASE_DIR
,
'role_keys/user/'
),
key_dir
=
os
.
path
.
join
(
KEY_DIR
,
'user'
),
authorized_keys
=
True
,
home
=
"/home"
,
length
=
2048
):
"""
...
...
juser/views.py
View file @
67771105
...
...
@@ -8,14 +8,11 @@ import uuid as uuid_r
from
django.contrib.auth.decorators
import
login_required
from
django.db.models
import
Q
from
django.template
import
RequestContext
from
django.db.models
import
ObjectDoesNotExist
from
jumpserver.settings
import
EMAIL_HOST_USER
from
juser.user_api
import
*
from
jperm.perm_api
import
_public_perm_api
,
perm_user_api
,
user_permed
MAIL_FROM
=
EMAIL_HOST_USER
def
chg_role
(
request
):
role
=
{
'SU'
:
2
,
'GA'
:
1
,
'CU'
:
0
}
if
request
.
session
[
'role_id'
]
>
0
:
...
...
@@ -142,54 +139,6 @@ def group_edit(request):
return
my_render
(
'juser/group_edit.html'
,
locals
(),
request
)
# @require_role(role='admin')
# def group_edit_adm(request):
# error = ''
# msg = ''
# header_title, path1, path2 = '修改小组信息', '用户管理', '编辑小组'
# user, dept = get_session_user_dept(request)
# if request.method == 'GET':
# group_id = request.GET.get('id', '')
# if not validate(request, user_group=[group_id]):
# return HttpResponseRedirect('/juser/group_list/')
# group = UserGroup.objects.filter(id=group_id)
# if group:
# group = group[0]
# users_all = dept.user_set.all()
# users_selected = group.user_set.all()
# users = [user for user in users_all if user not in users_selected]
#
# return render_to_response('juser/group_edit.html', locals(), context_instance=RequestContext(request))
# else:
# group_id = request.POST.get('group_id', '')
# group_name = request.POST.get('group_name', '')
# comment = request.POST.get('comment', '')
# users_selected = request.POST.getlist('users_selected')
#
# users = []
# try:
# if not validate(request, user=users_selected):
# raise ServerError(u'右侧非部门用户')
#
# if not validate(request, user_group=[group_id]):
# raise ServerError(u'没有权限修改本组')
#
# for user_id in users_selected:
# users.extend(User.objects.filter(id=user_id))
#
# user_group = UserGroup.objects.filter(id=group_id)
# if user_group:
# user_group.update(name=group_name, comment=comment, dept=dept)
# user_group = user_group[0]
# user_group.user_set.clear()
# user_group.user_set = users
#
# except ServerError, e:
# error = e
#
# return HttpResponseRedirect('/juser/group_list/')
@login_required
(
login_url
=
'/login'
)
@require_role
(
role
=
'super'
)
def
user_add
(
request
):
...
...
@@ -210,7 +159,7 @@ def user_add(request):
uuid
=
uuid_r
.
uuid1
()
ssh_key_pwd
=
PyCrypt
.
gen_rand_pass
(
16
)
extra
=
request
.
POST
.
getlist
(
'extra'
,
[])
is_active
=
True
if
'0'
in
extra
else
Fals
e
is_active
=
False
if
'0'
in
extra
else
Tru
e
ssh_key_login_need
=
True
if
'1'
in
extra
else
False
send_mail_need
=
True
if
'2'
in
extra
else
False
...
...
@@ -437,7 +386,6 @@ def user_edit(request):
admin_groups
=
admin_groups
,
role
=
role_post
,
is_active
=
is_active
)
_public_perm_api
({
'type'
:
'del_user'
,
'user'
:
user
,
'asset'
:
user_permed
(
user
)})
if
email_need
:
msg
=
u"""
...
...
@@ -528,7 +476,7 @@ def down_key(request):
user
=
get_object
(
User
,
id
=
user_id
)
if
user
:
username
=
user
.
username
private_key_file
=
os
.
path
.
join
(
BASE_DIR
,
'role_keys/jumpserver'
,
username
+
".pem"
)
private_key_file
=
os
.
path
.
join
(
KEY_DIR
,
'user'
,
username
)
if
os
.
path
.
isfile
(
private_key_file
):
f
=
open
(
private_key_file
)
data
=
f
.
read
()
...
...
static/js/base.js
View file @
67771105
...
...
@@ -17,10 +17,19 @@ function check_all(form) {
}
function
checkAll
(){
// 选择该页面所有checkbox
$
(
'input[type=checkbox]'
).
each
(
function
(){
$
(
this
).
attr
(
'checked'
,
true
)
})
var
checklist
=
document
.
getElementsByName
(
"checked"
);
if
(
document
.
getElementById
(
"check_all"
).
checked
)
{
for
(
var
i
=
0
;
i
<
checklist
.
length
;
i
++
)
{
checklist
[
i
].
checked
=
1
;
}
}
else
{
for
(
var
j
=
0
;
j
<
checklist
.
length
;
j
++
)
{
checklist
[
j
].
checked
=
0
;
}
}
}
//提取指定行的数据,JSON格式
...
...
templates/juser/group_list.html
View file @
67771105
...
...
@@ -43,7 +43,7 @@
<thead>
<tr>
<th
class=
"text-center"
>
<input
type=
"checkbox"
id=
"
select_all"
onclick=
"selectAll()"
name=
"select
_all"
>
<input
type=
"checkbox"
id=
"
check_all"
onclick=
"checkAll()"
name=
"check
_all"
>
</th>
<th
class=
"text-center"
>
组名
</th>
<th
class=
"text-center"
>
成员数目
</th>
...
...
@@ -55,7 +55,7 @@
{% for group in user_groups.object_list %}
<tr
class=
"gradeX"
>
<td
class=
"text-center"
>
<input
type=
"checkbox"
name=
"
select
ed"
value=
"{{ group.id }}"
>
<input
type=
"checkbox"
name=
"
check
ed"
value=
"{{ group.id }}"
>
</td>
<td
class=
"text-center"
>
{{ group.name }}
</td>
<td
class=
"text-center"
><a
href=
"/juser/user_list/?gid={{ group.id }}"
>
{{ group.id | members_count }}
</a>
</td>
...
...
templates/juser/user_add.html
View file @
67771105
...
...
@@ -93,10 +93,10 @@
</div>
</div>
<div
class=
"hr-line-dashed"
></div>
<div
class=
"form-group"
><label
class=
"col-sm-2 control-label"
>
额外
</label>
<div
class=
"form-group"
><label
class=
"col-sm-2 control-label"
>
其它
</label>
<div
class=
"col-sm-2"
>
<div
class=
"checkbox i-checks"
>
<label><input
type=
"checkbox"
value=
"0"
name=
"extra"
>
启
用
</label>
<label><input
type=
"checkbox"
value=
"0"
name=
"extra"
>
禁
用
</label>
</div>
</div>
<div
class=
"col-sm-2"
>
...
...
templates/juser/user_edit.html
View file @
67771105
...
...
@@ -40,7 +40,7 @@
<div
class=
"form-group"
>
<label
for=
"password"
class=
"col-sm-2 control-label"
>
密码
</label>
<div
class=
"col-sm-8"
>
<input
id=
"password"
name=
"password"
placeholder=
"Password"
type=
"password"
class=
"form-control"
>
<input
id=
"password"
name=
"password"
placeholder=
"Password"
type=
"password"
class=
"form-control"
value=
"{{ user.password }}"
>
<span
class=
"help-block m-b-none"
>
登陆web的密码
</span>
...
...
templates/juser/user_list.html
View file @
67771105
...
...
@@ -42,7 +42,7 @@
<thead>
<tr>
<th
class=
"text-center"
>
<input
type=
"checkbox"
id=
"
select_all"
onclick=
"selectAll()"
name=
"select_all
"
>
<input
type=
"checkbox"
id=
"
check_all"
onclick=
"checkAll()
"
>
</th>
<th
class=
"text-center"
>
用户名
</th>
<th
class=
"text-center"
>
姓名
</th>
...
...
@@ -57,7 +57,7 @@
{% for user in users.object_list %}
<tr
class=
"gradeX"
>
<td
class=
"text-center"
>
<input
type=
"checkbox"
name=
"select
ed"
value=
"{{ user.id }}"
>
<input
type=
"checkbox"
name=
"check
ed"
value=
"{{ user.id }}"
>
</td>
<td
class=
"text-center"
>
{{ user.username }}
</td>
<td
class=
"text-center"
>
{{ user.name }}
</td>
...
...
templates/paginator.html
View file @
67771105
...
...
@@ -55,9 +55,7 @@
searchArray
.
pop
();
}
console
.
log
(
searchStr
);
searchArray
.
push
(
old_href
);
console
.
log
(
searchArray
);
if
(
searchArray
.
length
>
1
)
{
$
(
this
).
attr
(
'href'
,
searchArray
.
join
(
'&'
));
}
...
...
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