pull/26/head
ibuler 2015-12-07 18:06:07 +08:00
parent cb12b83e47
commit 5be2633795
4 changed files with 8 additions and 42 deletions

View File

@ -195,9 +195,9 @@ def get_display_msg(user, password, ssh_key_pwd, ssh_key_login_need, send_mail_n
用户名%s 用户名%s
密码%s 密码%s
密钥密码%s 密钥密码%s
密钥下载url: %s/juser/down_key/?id=%s 密钥下载url: %s/juser/down_key/?uuid=%s
该账号密码可以登陆web和跳板机 该账号密码可以登陆web和跳板机
""" % (URL, user.username, password, ssh_key_pwd, URL, user.id) """ % (URL, user.username, password, ssh_key_pwd, URL, user.uuid)
else: else:
msg = u""" msg = u"""
跳板机地址 %s \n 跳板机地址 %s \n

View File

@ -13,15 +13,6 @@ from jperm.perm_api import get_group_user_perm
MAIL_FROM = EMAIL_HOST_USER MAIL_FROM = EMAIL_HOST_USER
@login_required(login_url='/login')
def chg_role(request):
role = {'SU': 2, 'GA': 1, 'CU': 0}
if request.session['role_id'] > 0:
request.session['role_id'] = 0
elif request.session['role_id'] == 0:
request.session['role_id'] = role.get(request.user.role, 0)
return HttpResponseRedirect('/')
@require_role(role='super') @require_role(role='super')
def group_add(request): def group_add(request):
@ -128,7 +119,6 @@ def group_edit(request):
continue continue
user.group.add(g) user.group.add(g)
except ServerError, e: except ServerError, e:
error = e error = e
if not error: if not error:
@ -141,7 +131,6 @@ def group_edit(request):
return my_render('juser/group_edit.html', locals(), request) return my_render('juser/group_edit.html', locals(), request)
@login_required(login_url='/login')
@require_role(role='super') @require_role(role='super')
def user_add(request): def user_add(request):
error = '' error = ''
@ -307,6 +296,7 @@ def forget_password(request):
return render_to_response('juser/forget_password.html', locals()) return render_to_response('juser/forget_password.html', locals())
@require_role('user')
def reset_password(request): def reset_password(request):
uuid_r = request.GET.get('uuid', '') uuid_r = request.GET.get('uuid', '')
timestamp = request.GET.get('timestamp', '') timestamp = request.GET.get('timestamp', '')
@ -401,14 +391,11 @@ def user_edit(request):
def profile(request): def profile(request):
a = request.user.id
a = request.user.groups
user_id = request.user.id user_id = request.user.id
if not user_id: if not user_id:
return HttpResponseRedirect('/') return HttpResponseRedirect('/')
user = User.objects.get(id=user_id) user = User.objects.get(id=user_id)
return render_to_response('juser/profile.html', locals(), context_instance=RequestContext(request)) return my_render('juser/profile.html', locals(), request)
def change_info(request): def change_info(request):
@ -440,7 +427,7 @@ def change_info(request):
user.save() user.save()
msg = '修改成功' msg = '修改成功'
return render_to_response('juser/change_info.html', locals(), context_instance=RequestContext(request)) return my_render('juser/change_info.html', locals(), request)
@require_role(role='user') @require_role(role='user')
@ -467,7 +454,8 @@ def down_key(request):
user = get_object(User, uuid=uuid_r) user = get_object(User, uuid=uuid_r)
if user: if user:
username = user.username username = user.username
private_key_file = os.path.join(KEY_DIR, 'user', username) private_key_file = os.path.join(KEY_DIR, 'user', username+'pem')
print private_key_file
if os.path.isfile(private_key_file): if os.path.isfile(private_key_file):
f = open(private_key_file) f = open(private_key_file)
data = f.read() data = f.read()

View File

@ -26,21 +26,16 @@
<td class="text-center">角色</td> <td class="text-center">角色</td>
<td class="text-center">Email</td> <td class="text-center">Email</td>
<td class="text-center">激活</td> <td class="text-center">激活</td>
{# <td class="text-center">添加时间</td>#}
{# <td class="text-center">最后登录</td>#}
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr class="gradeX"> <tr class="gradeX">
<td class="text-center">{{ user.id }}</td> <td class="text-center">{{ user.id }}</td>
<td class="text-center">{{ user.username }}</td> <td class="text-center">{{ user.username }}</td>
<td class="text-center">{{ user.name }}</td> <td class="text-center">{{ user.name }}</td>
<td class="text-center">{{ user.id | get_role }}</td> <td class="text-center">{{ user.id | get_role }}</td>
<td class="text-center">{{ user.email }}</td> <td class="text-center">{{ user.email }}</td>
<td class="text-center">{{ user.is_active|bool2str }}</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>
<tr> <tr>
<td class="text-center">添加日期: </td> <td class="text-center">添加日期: </td>
@ -56,23 +51,6 @@
{% endfor %} {% endfor %}
</td> </td>
</tr> </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> </table>
</div> </div>
</div> </div>

View File

@ -42,7 +42,7 @@
<thead> <thead>
<tr> <tr>
<th class="text-center"> <th class="text-center">
<input type="checkbox" id="check_all" onclick="checkAll()"> <input type="checkbox" id="check_all" onclick="checkAll('check_all', 'checked')">
</th> </th>
<th class="text-center">用户名</th> <th class="text-center">用户名</th>
<th class="text-center">姓名</th> <th class="text-center">姓名</th>