From f12fe007668a520539f07fb4065b00cfb0d10356 Mon Sep 17 00:00:00 2001 From: baoliang Date: Thu, 29 Apr 2021 21:57:14 +0800 Subject: [PATCH] fix manager change bug --- polls/views/__pycache__/media.cpython-39.pyc | Bin 11010 -> 10965 bytes polls/views/media.py | 26 +++++++------------ 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/polls/views/__pycache__/media.cpython-39.pyc b/polls/views/__pycache__/media.cpython-39.pyc index 3ee044ed096714ea0b3df3910cfc1cf3490fb144..9208f58bbb8746e1d30e7e48c9cd12b3a25dd1a1 100644 GIT binary patch delta 678 zcma)&&ubGw6vyXHlHKh#*=&+Fn>H~&XcAn#h`5;@)Eo-ENDm&pNWBC+rdRPVh%?dlAO)SnXPEcCkN08LZhf0ImSQoT zi1XuM^GqB*&>$R>QVG$N*YKyMJ4DnTw ziSr>&xynqIXoTy-EXkEclPm2+KtLqg$$-?OEQO1C>q&~oUBw*A}n5F*d?R zS(>Y^#VnQyG$2h_P5T*curVH64~cYyjf?)+Ad_v;6N9rXn^4<1+w=TDH1|jJ++U({ zK{kLB*|~qq=1*mh{zsOP8DbakOMW$PgLhec{ez^y@$;?Y)!4#uv^@b6hXEM8HWbI4=R{sM8wvKjyY delta 685 zcmcZ_+7!l@$ji&c00i?dHzyc+ZsZGHOwXa z3j`K2r114J#W2-!)^gQw6}>272g(W7aMm!@u&3~+2=ubla_1?4MLBCYQ+RqA7jP|P zsO3)Kui=gts^MNBypVyBAw{r;4aj4I@JiShhyc~_qzFyUl@+fSt>MpN%Mx42$jDG4 zzCZ%ZldR!Q5l#_F5v^g*l1vdx5nsr`$S{Gi(4a)BhA%~;hPRm+sG2oJ5-2YXRwFfs zDTRFwQ!`^Q18(ltnMG4*@-kIPM#jndisF+ms|s!oSL|luDe3?!FY*ErU6cPPFBIqjF+pY& z^@51L$!k@jMf*X_R1h%%L`(z`lP1fm+OU-|GB6YuO#Ub=J-JFXl5xu9^Ww6bKdP=^ z5&-M5L1>)Zr(nXKlA4oRlDc{F6AgdHshdqSr5FV!gOp4G5mP~g^5l)u!jlWNBDw9E L7?~J(tU)9I&OEgP diff --git a/polls/views/media.py b/polls/views/media.py index 2bfcf04..486cfda 100644 --- a/polls/views/media.py +++ b/polls/views/media.py @@ -329,14 +329,11 @@ def media_admin_change(request): if o.is_direct(): # 如果是省直 obj, created = UserModel.objects.get_or_create( - username=phone, last_login=datetime.now()) - if created: - p = Userprofile.objects.create( - user=obj, name=name, organization=o, admin_status=2) - else: - p = Userprofile.objects.filter(user=obj).first() - p.admin_status = 2 - p.save() + username=phone) + if not created: + return JsonResponse({'status': 'error', 'message': '手机号已存在'}) + p = Userprofile.objects.create( + user=obj, name=name, organization=o, admin_status=2) profile.admin_status = 5 profile.save() managers = Userprofile.level1_admin() @@ -350,14 +347,11 @@ def media_admin_change(request): return JsonResponse({'status': 'success', 'message': {'title': o.name, 'organizationId': o.id}}) else: obj, created = UserModel.objects.get_or_create( - username=phone, last_login=datetime.now()) - if created: - p = Userprofile.objects.create( - user=obj, name=name, organization=o, admin_status=1) - else: - p = Userprofile.objects.filter(user=obj).first() - p.admin_status = 2 - p.save() + username=phone) + if not created: + return JsonResponse({'status': 'error', 'message': '手机号已存在'}) + p = Userprofile.objects.create( + user=obj, name=name, organization=o, admin_status=1) profile.admin_status = 4 profile.save() managers = Userprofile.level2_admin(o.cities)