fix manager change bug

This commit is contained in:
baoliang 2021-04-29 21:57:14 +08:00
parent bfe9ad0fba
commit f12fe00766
2 changed files with 10 additions and 16 deletions

View File

@ -329,14 +329,11 @@ def media_admin_change(request):
if o.is_direct(): # 如果是省直 if o.is_direct(): # 如果是省直
obj, created = UserModel.objects.get_or_create( obj, created = UserModel.objects.get_or_create(
username=phone, last_login=datetime.now()) username=phone)
if created: if not created:
p = Userprofile.objects.create( return JsonResponse({'status': 'error', 'message': '手机号已存在'})
user=obj, name=name, organization=o, admin_status=2) p = Userprofile.objects.create(
else: user=obj, name=name, organization=o, admin_status=2)
p = Userprofile.objects.filter(user=obj).first()
p.admin_status = 2
p.save()
profile.admin_status = 5 profile.admin_status = 5
profile.save() profile.save()
managers = Userprofile.level1_admin() managers = Userprofile.level1_admin()
@ -350,14 +347,11 @@ def media_admin_change(request):
return JsonResponse({'status': 'success', 'message': {'title': o.name, 'organizationId': o.id}}) return JsonResponse({'status': 'success', 'message': {'title': o.name, 'organizationId': o.id}})
else: else:
obj, created = UserModel.objects.get_or_create( obj, created = UserModel.objects.get_or_create(
username=phone, last_login=datetime.now()) username=phone)
if created: if not created:
p = Userprofile.objects.create( return JsonResponse({'status': 'error', 'message': '手机号已存在'})
user=obj, name=name, organization=o, admin_status=1) p = Userprofile.objects.create(
else: user=obj, name=name, organization=o, admin_status=1)
p = Userprofile.objects.filter(user=obj).first()
p.admin_status = 2
p.save()
profile.admin_status = 4 profile.admin_status = 4
profile.save() profile.save()
managers = Userprofile.level2_admin(o.cities) managers = Userprofile.level2_admin(o.cities)