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'))