From 69061791edf9e4d1bc5601040ed4350ce50c3576 Mon Sep 17 00:00:00 2001 From: ibuler Date: Fri, 25 Mar 2016 17:18:41 +0800 Subject: [PATCH] =?UTF-8?q?fix(user=20edit)=20=E4=BF=AE=E6=94=B9=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E5=AF=BC=E8=87=B4=E5=AF=86=E7=A0=81=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 简单修改,更改结构和变量名 close #160 --- juser/user_api.py | 8 ++++---- juser/views.py | 7 +------ 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/juser/user_api.py b/juser/user_api.py index 020a009fd..f2964eade 100644 --- a/juser/user_api.py +++ b/juser/user_api.py @@ -87,12 +87,12 @@ def db_update_user(**kwargs): admin_groups_post = kwargs.pop('admin_groups') user_id = kwargs.pop('user_id') user = User.objects.filter(id=user_id) - user_get = User.objects.get(id=user_id) if user: - pwd = kwargs.pop('password') + user_get = user[0] + password = kwargs.pop('password') user.update(**kwargs) - if pwd != '': - user_get.set_password(pwd) + if password.strip(): + user_get.set_password(password) user_get.save() else: return None diff --git a/juser/views.py b/juser/views.py index a1a514def..90c3d2f53 100644 --- a/juser/views.py +++ b/juser/views.py @@ -368,11 +368,6 @@ def user_edit(request): else: return HttpResponseRedirect(reverse('user_list')) - if password != '': - password_decode = password - else: - password_decode = None - db_update_user(user_id=user_id, password=password, name=name, @@ -391,7 +386,7 @@ def user_edit(request): 密码:%s (如果密码为None代表密码为原密码) 权限::%s - """ % (user.name, URL, user.username, password_decode, user_role.get(role_post, u'')) + """ % (user.name, URL, user.username, password, user_role.get(role_post, u'')) send_mail('您的信息已修改', msg, MAIL_FROM, [email], fail_silently=False) return HttpResponseRedirect(reverse('user_list'))