mirror of https://github.com/jumpserver/jumpserver
修改用户详情
parent
2e5b22417d
commit
a998de5973
|
@ -1,12 +1,18 @@
|
|||
from juser.models import User
|
||||
from jasset.models import Asset
|
||||
|
||||
from jumpserver.api import *
|
||||
|
||||
def name_proc(request):
|
||||
user_id = request.session.get('user_id')
|
||||
role_id = request.session.get('role_id')
|
||||
user_total_num = User.objects.all().count()
|
||||
user_active_num = User.objects.filter(is_active=True).count()
|
||||
if role_id == 2:
|
||||
user_total_num = User.objects.all().count()
|
||||
user_active_num = User.objects.filter().count()
|
||||
else:
|
||||
user, dept = get_session_user_dept(request)
|
||||
user_total_num = dept.user_set.all().count()
|
||||
user_active_num = dept.user_set.filter(is_active=True).count()
|
||||
|
||||
host_total_num = Asset.objects.all().count()
|
||||
host_active_num = Asset.objects.filter(is_active=True).count()
|
||||
request.session.set_expiry(3600)
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
# coding: utf-8
|
||||
|
||||
import re
|
||||
import time
|
||||
|
||||
from django import template
|
||||
from juser.models import User, UserGroup, DEPT
|
||||
from jasset.models import BisGroup
|
||||
from jumpserver.api import *
|
||||
|
||||
register = template.Library()
|
||||
|
@ -179,12 +177,19 @@ def to_name(user_id):
|
|||
except:
|
||||
return '闈炴硶鐢ㄦ埛'
|
||||
|
||||
|
||||
@register.filter(name='to_role_name')
|
||||
def to_role_name(role_id):
|
||||
role_dict = {'0': '鏅氱敤鎴', '1': '閮ㄩ棬绠$悊鍛', '2': '瓒呯骇绠$悊鍛'}
|
||||
return role_dict.get(str(role_id), '鏈煡')
|
||||
|
||||
|
||||
@register.filter(name='to_avatar')
|
||||
def to_avatar(role_id='0'):
|
||||
role_dict = {'0': 'user', '1': 'admin', '2': 'root'}
|
||||
return role_dict.get(str(role_id), 'user')
|
||||
|
||||
|
||||
@register.filter(name='get_user_asset_group')
|
||||
def get_user_asset_group(user):
|
||||
return user_perm_group_api(user)
|
|
@ -27,6 +27,6 @@ urlpatterns = patterns('juser.views',
|
|||
(r'^user_del_ajax/$', 'user_del_ajax'),
|
||||
(r'^user_edit/$', view_splitter, {'su': user_edit, 'adm': user_edit_adm}),
|
||||
(r'^profile/$', 'profile'),
|
||||
(r'^chg_pass/$', 'chg_pass'),
|
||||
(r'^chg_info/$', 'chg_info'),
|
||||
(r'^chg_role/$', 'chg_role'),
|
||||
)
|
||||
|
|
|
@ -233,10 +233,13 @@ def dept_list_adm(request):
|
|||
return render_to_response('juser/dept_list.html', locals(), context_instance=RequestContext(request))
|
||||
|
||||
|
||||
|
||||
@require_admin
|
||||
def chg_role(request):
|
||||
request.session['role_id'] = 0
|
||||
role = {'SU': 2, 'DA': 1, 'CU': 0}
|
||||
user, dept = get_session_user_dept(request)
|
||||
if request.session['role_id'] > 0:
|
||||
request.session['role_id'] = 0
|
||||
elif request.session['role_id'] == 0:
|
||||
request.session['role_id'] = role.get(user.role, 0)
|
||||
return HttpResponseRedirect('/')
|
||||
|
||||
|
||||
|
@ -953,8 +956,36 @@ def profile(request):
|
|||
return render_to_response('juser/user_detail.html', locals(), context_instance=RequestContext(request))
|
||||
|
||||
|
||||
def chg_pass(request):
|
||||
def chg_info(request):
|
||||
header_title, path1, path2 = '淇敼淇℃伅 | Edit Info', '鐢ㄦ埛绠$悊', '淇敼涓汉淇℃伅'
|
||||
user_id = request.session.get('user_id')
|
||||
user_set = User.objects.filter(id=user_id)
|
||||
error = ''
|
||||
if user_set:
|
||||
user = user_set[0]
|
||||
else:
|
||||
return HttpResponseRedirect('/')
|
||||
|
||||
return render_to_response('juser/user_add.html', locals(), context_instance=RequestContext(request))
|
||||
if request.method == 'POST':
|
||||
name = request.POST.get('name', '')
|
||||
password = request.POST.get('password', '')
|
||||
ssh_key_pwd = request.POST.get('ssh_key_pwd', '')
|
||||
email = request.POST.get('email', '')
|
||||
|
||||
if '' in [name, password, ssh_key_pwd, email]:
|
||||
error = '涓嶈兘涓虹┖'
|
||||
|
||||
if len(password) < 6 or len(ssh_key_pwd) < 6:
|
||||
error = '瀵嗙爜椤诲ぇ浜6浣'
|
||||
|
||||
if not error:
|
||||
if password != user.password:
|
||||
password = md5_crypt(password)
|
||||
|
||||
if ssh_key_pwd != user.ssh_key_pwd:
|
||||
ssh_key_pwd = md5_crypt(ssh_key_pwd)
|
||||
user_set.update(name=name, password=password, ssh_key_pwd=ssh_key_pwd, email=email)
|
||||
msg = '淇敼鎴愬姛'
|
||||
|
||||
return render_to_response('juser/chg_info.html', locals(), context_instance=RequestContext(request))
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<div class="footer fixed">
|
||||
<div class="pull-right">
|
||||
Version <strong>1.2.0</strong> GPL.
|
||||
Version <strong>2.0.0</strong> GPL.
|
||||
</div>
|
||||
<div>
|
||||
<strong>Copyright</strong> Jumpserver.org Organization © 2014-2015
|
||||
|
|
|
@ -66,7 +66,7 @@
|
|||
<tr class="gradeX">
|
||||
<td class="text-center"> {{ group.name }} </td>
|
||||
<td class="text-center"> {{ group.dept.name }} </td>
|
||||
<td class="text-center"><a href="/juser/user_list/?did={{ group.id }}">{{ group.id | member_count }} </a> </td>
|
||||
<td class="text-center"><a href="/juser/user_list/?gid={{ group.id }}">{{ group.id | member_count }} </a> </td>
|
||||
<td class="text-center"> {{ group.id | ugrp_perm_agrp_count }} </td>
|
||||
<td class="text-center"> {{ group.id | ugrp_perm_asset_count }} </td>
|
||||
<td class="text-center"> {{ group.id | ugrp_perm_asset_count }} </td>
|
||||
|
@ -116,28 +116,7 @@
|
|||
|
||||
});
|
||||
|
||||
{# $(document).ready(function(){#}
|
||||
{# $('#search_btn').click(function(){#}
|
||||
{# if ($('#tab2').attr('class') == 'active'){#}
|
||||
{# var tab='tab2'#}
|
||||
{# } else {#}
|
||||
{# var tab='tab1'#}
|
||||
{# }#}
|
||||
{##}
|
||||
{# var search=$('#search_input').val()#}
|
||||
{##}
|
||||
{# $.post('/jperm/perm_list_ajax/',#}
|
||||
{# {'tab': tab, 'search': search},#}
|
||||
{# function(data){#}
|
||||
{# if ($('#tab2').attr('class') == 'active'){#}
|
||||
{# $('#tab-2').html(data)#}
|
||||
{# } else {#}
|
||||
{# $('#tab-1').html(data)#}
|
||||
{# }#}
|
||||
{# })#}
|
||||
{##}
|
||||
{# })#}
|
||||
{# })#}
|
||||
|
||||
</script>
|
||||
|
||||
{% endblock %}
|
|
@ -0,0 +1,132 @@
|
|||
{% extends 'base.html' %}
|
||||
{% load mytags %}
|
||||
|
||||
|
||||
{% block content %}
|
||||
{% include 'nav_cat_bar.html' %}
|
||||
<div class="wrapper wrapper-content animated fadeInRight">
|
||||
<div class="row">
|
||||
<div class="col-lg-10">
|
||||
<div class="ibox float-e-margins">
|
||||
<div class="ibox-title">
|
||||
<h5>缂栬緫鐢ㄦ埛淇℃伅</h5>
|
||||
<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">
|
||||
<li><a href="#">鏈惎鐢 1</a>
|
||||
</li>
|
||||
<li><a href="#">鏈惎鐢 2</a>
|
||||
</li>
|
||||
</ul>
|
||||
<a class="close-link">
|
||||
<i class="fa fa-times"></i>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="ibox-content">
|
||||
<form method="post" id="userForm" class="form-horizontal" action="">
|
||||
{% if error %}
|
||||
<div class="alert alert-warning text-center">{{ error }}</div>
|
||||
{% endif %}
|
||||
{% if msg %}
|
||||
<div class="alert alert-success text-center">{{ msg }}</div>
|
||||
{% endif %}
|
||||
<div class="form-group">
|
||||
<div class="col-sm-8">
|
||||
<input id="user_id" name="user_id" type="text" value="{{ user.id }}" style="display: none">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="name" class="col-sm-2 control-label">濮撳悕<span class="red-fonts">*</span></label>
|
||||
<div class="col-sm-8">
|
||||
<input id="name" name="name" placeholder="Name" type="text" class="form-control" value="{{ user.name }}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="hr-line-dashed"></div>
|
||||
<div class="form-group">
|
||||
<label for="password" class="col-sm-2 control-label">瀵嗙爜<span class="red-fonts">*</span></label>
|
||||
<div class="col-sm-8">
|
||||
<input id="password" name="password" placeholder="Password" type="password" class="form-control" value="{{ user.password }}">
|
||||
<span class="help-block m-b-none">
|
||||
鐧婚檰web鐨勫瘑鐮
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="hr-line-dashed"></div>
|
||||
<div class="form-group">
|
||||
<label for="ssh_key_pwd" class="col-sm-2 control-label">瀵嗛挜瀵嗙爜<span class="red-fonts">*</span></label>
|
||||
<div class="col-sm-8">
|
||||
<input id="ssh_key_pwd" name="ssh_key_pwd" placeholder="SSH Key Password" type="password" class="form-control" value="{{ user.ssh_key_pwd }}">
|
||||
<span class="help-block m-b-none">
|
||||
鐧婚檰 Jumpserver 浣跨敤鐨凷SH瀵嗛挜鐨勫瘑鐮
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="hr-line-dashed"></div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="email" class="col-sm-2 control-label">Email<span class="red-fonts">*</span></label>
|
||||
<div class="col-sm-8">
|
||||
<input id="email" name="email" type="email" placeholder="Email" class="form-control" value="{{ user.email }}" >
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="hr-line-dashed"></div>
|
||||
<div class="form-group">
|
||||
<div class="col-sm-4 col-sm-offset-2">
|
||||
<button class="btn btn-white" type="submit">鍙栨秷</button>
|
||||
<button id="submit_button" class="btn btn-primary" type="submit">纭淇敼</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
$('#userForm').validator({
|
||||
timely: 2,
|
||||
theme: "yellow_right_effect",
|
||||
|
||||
fields: {
|
||||
"password": {
|
||||
rule: "required;length[6~50]",
|
||||
tip: "杈撳叆瀵嗙爜",
|
||||
ok: "",
|
||||
msg: {required: "蹇呴』濉啓!"}
|
||||
},
|
||||
"ssh_key_pwd": {
|
||||
rule: "required;length[6~50]",
|
||||
tip: "ssh绉侀挜瀵嗙爜",
|
||||
ok: "",
|
||||
msg: {required: "蹇呴』濉啓"}
|
||||
},
|
||||
"name": {
|
||||
rule: "required",
|
||||
tip: "濮撳悕",
|
||||
ok: "",
|
||||
msg: {required: "蹇呴』濉啓"}
|
||||
},
|
||||
"email": {
|
||||
rule: "required",
|
||||
tip: "Email",
|
||||
ok: "",
|
||||
msg: {required: "蹇呴』濉啓"}
|
||||
},
|
||||
},
|
||||
valid: function(form) {
|
||||
form.submit();
|
||||
}
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
{% endblock %}
|
|
@ -20,65 +20,61 @@
|
|||
<table class="table table-striped table-bordered table-hover " id="editable" >
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="text-center">鐢ㄦ埛</th>
|
||||
<th class="text-center">璇︽儏</th>
|
||||
<td class="text-center" width="120">ID</td>
|
||||
<td class="text-center">鐢ㄦ埛鍚</td>
|
||||
<td class="text-center">濮撳悕</td>
|
||||
<td class="text-center">瑙掕壊</td>
|
||||
<td class="text-center">閮ㄩ棬</td>
|
||||
<td class="text-center">Email</td>
|
||||
<td class="text-center">婵娲</td>
|
||||
{# <td class="text-center">娣诲姞鏃堕棿</td>#}
|
||||
{# <td class="text-center">鏈鍚庣櫥褰</td>#}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr class="gradeX">
|
||||
<td class="text-center">ID</td>
|
||||
|
||||
<td class="text-center">{{ user.id }}</td>
|
||||
</tr>
|
||||
<tr class="gradeX">
|
||||
<td class="text-center">username</td>
|
||||
<td class="text-center">{{ user.username }}</td>
|
||||
</tr>
|
||||
<tr class="gradeX">
|
||||
<td class="text-center">濮撳悕</td>
|
||||
<td class="text-center">{{ user.name }}</td>
|
||||
</tr>
|
||||
<tr class="gradeX">
|
||||
<td class="text-center">瑙掕壊</td>
|
||||
<td class="text-center">{{ user.id }}</td>
|
||||
</tr>
|
||||
<tr class="gradeX">
|
||||
<td class="text-center">閮ㄩ棬</td>
|
||||
<td class="text-center">
|
||||
{{ user.dept.name }}
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="gradeX">
|
||||
<td class="text-center">灏忕粍</td>
|
||||
<td class="text-center">
|
||||
{% for group in user.user_group.all %}
|
||||
{{ group.name }}
|
||||
{% endfor %}
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="gradeX">
|
||||
<td class="text-center">Email</td>
|
||||
<td class="text-center">{{ user.id | get_role }}</td>
|
||||
<td class="text-center">{{ user.dept.name }}</td>
|
||||
<td class="text-center">{{ user.email }}</td>
|
||||
</tr>
|
||||
<tr class="gradeX">
|
||||
<td class="text-center">婵娲</td>
|
||||
<td class="text-center">{{ user.is_active|bool2str }}</td>
|
||||
{# <td class="text-center">{{ user.date_joined }}</td>#}
|
||||
{# <td class="text-center">{{ user.last_login }}</td>#}
|
||||
</tr>
|
||||
<tr class="gradeX">
|
||||
<td class="text-center">娣诲姞鏃堕棿</td>
|
||||
<td class="text-center">{{ user.date_joined }}</td>
|
||||
<tr>
|
||||
<td class="text-center">娣诲姞鏃ユ湡锛 </td>
|
||||
<td colspan="2" class="text-center">{{ user.date_joined }}</td>
|
||||
<td class="text-center">鏈鍚庣櫥褰曪細 </td>
|
||||
<td colspan="3" class="text-center">{{ user.last_login }}</td>
|
||||
</tr>
|
||||
<tr class="gradeX">
|
||||
<td class="text-center">鏈鍚庣櫥褰</td>
|
||||
<td class="text-center">{{ user.last_login }}</td>
|
||||
</tr>
|
||||
<tr class="gradeX">
|
||||
<td class="text-center">鎺堟潈涓绘満缁</td>
|
||||
<td class="text-center">
|
||||
{% for asset_group in asset_group_permed %}
|
||||
{{ asset_group.name }}
|
||||
<tr>
|
||||
<td colspan="1" class="text-center">鐢ㄦ埛缁勶細</td>
|
||||
<td colspan="6" class="text-center">
|
||||
{% for group in user.group.all %}
|
||||
<b>{{ group.name }}</b>
|
||||
{% endfor %}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="1" class="text-center">鎺堟潈涓绘満缁:</td>
|
||||
<td colspan="6" class="text-center">
|
||||
{% for group in user|get_user_asset_group %}
|
||||
<b>{{ group.name }}</b>
|
||||
{% endfor %}
|
||||
</td>
|
||||
</tr>
|
||||
{# #}
|
||||
{# <tr class="gradeX">#}
|
||||
{# <td class="text-center">鎺堟潈涓绘満缁</td>#}
|
||||
{# <td class="text-center">#}
|
||||
{# {% for asset_group in asset_group_permed %}#}
|
||||
{# {{ asset_group.name }}#}
|
||||
{# {% endfor %}#}
|
||||
{# </td>#}
|
||||
{# </tr>#}
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -72,7 +72,7 @@
|
|||
<td class="text-center"> {{ user.id | get_role }}</td>
|
||||
<td class="text-center">{{ user.is_active|bool2str }}</td>
|
||||
<td class="text-center">
|
||||
<a title="[ {{ user.name }} ] 璇︽儏" href="../user_detail/?id={{ user.id }}" class="iframe btn btn-xs btn-primary">璇︽儏</a>
|
||||
<a title="[ {{ user.name }} ] 璇︽儏" value="../user_detail/?id={{ user.id }}" class="iframe btn btn-xs btn-primary">璇︽儏</a>
|
||||
{% ifequal session_role_id 2 %}
|
||||
<a href="../user_edit/?id={{ user.id }}" class="btn btn-xs btn-info">缂栬緫</a>
|
||||
<a href="../user_del/?id={{ user.id }}" class="btn btn-xs btn-danger">鍒犻櫎</a>
|
||||
|
@ -80,7 +80,6 @@
|
|||
<a href="../user_edit/?id={{ user.id }}" class="btn btn-xs btn-info {% if user.id|user_readonly %} disabled {% endif %}">缂栬緫</a>
|
||||
<a href="../user_del/?id={{ user.id }}" class="btn btn-xs btn-danger {% if user.id|user_readonly %} disabled {% endif %}">鍒犻櫎</a>
|
||||
{% endifequal %}
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
@ -102,8 +101,21 @@
|
|||
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
$(".iframe").colorbox({iframe:true, width:"70%", height:"70%"});
|
||||
var check_array = []
|
||||
$(".iframe").on('click', function() {
|
||||
var url = $(this).attr("value");
|
||||
$.layer({
|
||||
type: 2,
|
||||
title: '鐢ㄦ埛璇︽儏',
|
||||
maxmin: true,
|
||||
shift: 'top',
|
||||
border: [2, 0.3, '#1AB394'],
|
||||
shade: [0.5, '#000000'],
|
||||
shadeClose: true,
|
||||
area: ['800px', '600px'],
|
||||
iframe: {src: url}
|
||||
})
|
||||
});
|
||||
var check_array = [];
|
||||
$('#del_btn').click(function(){
|
||||
if (confirm("纭畾鍒犻櫎")) {
|
||||
$(".gradeX input:checked").each(function() {check_array.push($(this).attr("value")) })
|
||||
|
|
|
@ -8,14 +8,9 @@
|
|||
<span class="clear"> <span class="block m-t-xs"> <strong class="font-bold">{{ session_user_id | to_name}}</strong>
|
||||
</span> <span class="text-muted text-xs block">{{ session_role_id | to_role_name }} <b class="caret"></b></span> </span> </a>
|
||||
<ul class="dropdown-menu animated fadeInRight m-t-xs">
|
||||
<li><a href="/juser/profile/">涓汉淇℃伅</a></li>
|
||||
<li><a href="/juser/chg_pass/">淇敼瀵嗙爜</a></li>
|
||||
{% ifequal session_role_id 2 %}
|
||||
<li><a href="/juser/chg_role/">鍒囨崲鏅氳鑹</a></li>
|
||||
{% endifequal %}
|
||||
{% ifequal session_role_id 1 %}
|
||||
<li><a href="/juser/chg_role/">鍒囨崲鏅氳鑹</a></li>
|
||||
{% endifequal %}
|
||||
<li><a value="/juser/user_detail/?id={{ session_user_id }}" class="iframe">涓汉淇℃伅</a></li>
|
||||
<li><a href="/juser/chg_info/">淇敼淇℃伅</a></li>
|
||||
<li><a href="/juser/chg_role/">鍒囨崲瑙掕壊</a></li>
|
||||
|
||||
<li class="divider"></li>
|
||||
<li><a href="/logout/">娉ㄩ攢</a></li>
|
||||
|
@ -25,4 +20,20 @@
|
|||
JS+
|
||||
</div>
|
||||
</li>
|
||||
<script>
|
||||
$(".iframe").on('click', function(){
|
||||
var url= $(this).attr("value");
|
||||
$.layer({
|
||||
type: 2,
|
||||
title: '涓汉淇℃伅',
|
||||
maxmin: true,
|
||||
shift: 'top',
|
||||
border: [2, 0.3, '#1AB394'],
|
||||
shade: [0.5, '#000000'],
|
||||
shadeClose: true,
|
||||
area : ['800px' , '600px'],
|
||||
iframe: {src: url}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
|
|
Loading鈥
Reference in New Issue