From 5be26337954993383a9f2047fe16fae133bcb8e9 Mon Sep 17 00:00:00 2001 From: ibuler Date: Mon, 7 Dec 2015 18:06:07 +0800 Subject: [PATCH] bug fix --- juser/user_api.py | 4 ++-- juser/views.py | 22 +++++----------------- templates/juser/profile.html | 22 ---------------------- templates/juser/user_list.html | 2 +- 4 files changed, 8 insertions(+), 42 deletions(-) diff --git a/juser/user_api.py b/juser/user_api.py index c9f82325c..36bb9319a 100644 --- a/juser/user_api.py +++ b/juser/user_api.py @@ -195,9 +195,9 @@ def get_display_msg(user, password, ssh_key_pwd, ssh_key_login_need, send_mail_n 用户名:%s 密码:%s 密钥密码:%s - 密钥下载url: %s/juser/down_key/?id=%s + 密钥下载url: %s/juser/down_key/?uuid=%s 该账号密码可以登陆web和跳板机。 - """ % (URL, user.username, password, ssh_key_pwd, URL, user.id) + """ % (URL, user.username, password, ssh_key_pwd, URL, user.uuid) else: msg = u""" 跳板机地址: %s \n diff --git a/juser/views.py b/juser/views.py index 3f75c46b8..df0ec1787 100644 --- a/juser/views.py +++ b/juser/views.py @@ -13,15 +13,6 @@ from jperm.perm_api import get_group_user_perm 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') def group_add(request): @@ -128,7 +119,6 @@ def group_edit(request): continue user.group.add(g) - except ServerError, e: error = e if not error: @@ -141,7 +131,6 @@ def group_edit(request): return my_render('juser/group_edit.html', locals(), request) -@login_required(login_url='/login') @require_role(role='super') def user_add(request): error = '' @@ -307,6 +296,7 @@ def forget_password(request): return render_to_response('juser/forget_password.html', locals()) +@require_role('user') def reset_password(request): uuid_r = request.GET.get('uuid', '') timestamp = request.GET.get('timestamp', '') @@ -401,14 +391,11 @@ def user_edit(request): def profile(request): - a = request.user.id - a = request.user.groups - user_id = request.user.id if not user_id: return HttpResponseRedirect('/') 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): @@ -440,7 +427,7 @@ def change_info(request): user.save() 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') @@ -467,7 +454,8 @@ def down_key(request): user = get_object(User, uuid=uuid_r) if user: 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): f = open(private_key_file) data = f.read() diff --git a/templates/juser/profile.html b/templates/juser/profile.html index 80d880ba7..a22386c4a 100644 --- a/templates/juser/profile.html +++ b/templates/juser/profile.html @@ -26,21 +26,16 @@ 角色 Email 激活 -{# 添加时间#} -{# 最后登录#} - {{ user.id }} {{ user.username }} {{ user.name }} {{ user.id | get_role }} {{ user.email }} {{ user.is_active|bool2str }} -{# {{ user.date_joined }}#} -{# {{ user.last_login }}#} 添加日期: @@ -56,23 +51,6 @@ {% endfor %} -{# #} -{# 授权主机组:#} -{# #} -{# {% for group in user|get_user_asset_group %}#} -{# {{ group.name }}#} -{# {% endfor %}#} -{# #} -{# #} -{# #} -{# #} -{# 授权主机组#} -{# #} -{# {% for asset_group in asset_group_permed %}#} -{# {{ asset_group.name }}#} -{# {% endfor %}#} -{# #} -{# #} diff --git a/templates/juser/user_list.html b/templates/juser/user_list.html index 01a62ccff..bce395fb5 100644 --- a/templates/juser/user_list.html +++ b/templates/juser/user_list.html @@ -42,7 +42,7 @@ - + 用户名 姓名