From 3967dadc26e0f2dcdbc53e6fa1758f1594ac944f Mon Sep 17 00:00:00 2001 From: baoliang Date: Sun, 25 Oct 2020 22:56:33 +0800 Subject: [PATCH 1/2] add message --- dashboard/models.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/dashboard/models.py b/dashboard/models.py index a8d7683..cae37b6 100644 --- a/dashboard/models.py +++ b/dashboard/models.py @@ -63,6 +63,9 @@ class Group(models.Model): def __str__(self): return self.name + class Meta: + ordering = ["rank"] + # 矩阵管理员 From 5a2529e12eafb82fee01467f1e447163ae2ba0f2 Mon Sep 17 00:00:00 2001 From: baoliang Date: Sun, 25 Oct 2020 23:59:04 +0800 Subject: [PATCH 2/2] add message --- dashboard/models.py | 1 + polls/views/__pycache__/user.cpython-38.pyc | Bin 6008 -> 6164 bytes polls/views/user.py | 9 +++++++-- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/dashboard/models.py b/dashboard/models.py index 749ea35..3efbd9d 100644 --- a/dashboard/models.py +++ b/dashboard/models.py @@ -102,6 +102,7 @@ class Group_user(models.Model): User, on_delete=models.CASCADE, null=True, blank=True) group = models.ForeignKey( Group, on_delete=models.CASCADE, null=True, blank=True) + status = models.IntegerField('status', default=1) created = models.DateTimeField('创建时间', auto_now_add=True) updated = models.DateTimeField('更新时间', auto_now=True) diff --git a/polls/views/__pycache__/user.cpython-38.pyc b/polls/views/__pycache__/user.cpython-38.pyc index ccdf190983908c9cf47c16675f8d68dc8d063096..086d6a7eb8f17338df21e2d5e94af2866f8e8e9f 100644 GIT binary patch delta 374 zcmeyNH^qQ2l$V!_0SMO3of@B`w2?1EWHOf!FVjAT$^N`S^(Cw|OwEibT-gjoStTqf ztSQ_n>~nx3!3;GFS!`MCwag_P%?!0HH7r@2StS8MUBk4Hk&ywYf@dKEBLh&LFNGf_uPNYHBo1^-kv@o!V_=x9Aj+**DhlL1?VJB} zecST|jZb#;zG&Y2WXG=OD|Z!%0A-@M^HR$L5{rw=^NUi7q9z-O8Yq_vp=o)xcJcFt z>x%S1<|Y9NP2S0QqDE%7_>wbHle6OsVA|tA3SvPD*ove;Y(XFq#RIefp(cFtS$^5c wS4Bm%RDhBUOk9jyj694ijC^pCkCB6s4anyLV-Cim)Xkh?LX3>5lV!wX0KP|N^Z)<= delta 271 zcmbPY@I#L;l$V!_0SK1KPl|U^+{l+9!p{oivH-C&5EpkaO!ntBsV`xzVQgkh;mBqv z@+o0SVNKyoVV}d)%oxm2!;r<6#a_!)!qLo7%Ur{p#hJxi!<53+%UH`&!?J*@hH)Vy zBLk4dy^w*C0jQTdg$Jfrlh?0E9B50CK8TP55rQB>2t-7I2oVqw%`kbYs1{d|9*C0! zBqpyEmYMuVR6?RC4kQ!{Bs5uzq(E%2{_x3X`DG`ki-{k7`YgE7+DzkfFvIy Z2O}Gh diff --git a/polls/views/user.py b/polls/views/user.py index 39e4734..1e0a82a 100644 --- a/polls/views/user.py +++ b/polls/views/user.py @@ -198,12 +198,17 @@ def reset_password(request): return HttpResponse(status=405) password = request.POST.get('password') if not password: + return JsonResponse({'status': 'error', 'message': '原密码不能为空'}) + new_password = request.POST.get('newPassword') + if not new_password: return JsonResponse({'status': 'error', 'message': '密码不能为空'}) - if len(password) < 6: + if len(new_password) < 6: return JsonResponse({'status': 'error', 'message': '密码长度不能少于6位'}) user_id = request.user.id UserModel = get_user_model() user = UserModel.objects.get(id=user_id) - user.set_password(password) + if not user.check_password(password): + return JsonResponse({'status': 'error', 'message': '原密码不正确'}) + user.set_password(new_password) user.save() return JsonResponse({'status': 'success', 'message': '密码修改成功'})