fix media admin change

This commit is contained in:
baoliang 2021-05-06 15:21:19 +08:00
parent 2ac0809e79
commit 14369170c6
1 changed files with 8 additions and 8 deletions

View File

@ -356,8 +356,8 @@ def media_admin_change(request):
else: else:
if UserModel.objects.filter(username=phone).exists(): if UserModel.objects.filter(username=phone).exists():
return JsonResponse({'status': 'error', 'message': '手机号已存在'}) return JsonResponse({'status': 'error', 'message': '手机号已存在'})
obj = UserModel.objects.get_or_create( obj = UserModel.objects.create(
username=phone) username=phone, last_login=datetime.now())
p = Userprofile.objects.create( p = Userprofile.objects.create(
user=obj, name=name, organization=o, admin_status=1) user=obj, name=name, organization=o, admin_status=1)
profile.admin_status = 4 profile.admin_status = 4
@ -394,10 +394,10 @@ def media_admin_add(request):
UserModel = get_user_model() UserModel = get_user_model()
if o.is_direct(): # 如果是省直 if o.is_direct(): # 如果是省直
obj, created = UserModel.objects.get_or_create( if UserModel.objects.filter(username=phone).exists():
username=phone)
if not created:
return JsonResponse({'status': 'error', 'message': '手机号已存在'}) return JsonResponse({'status': 'error', 'message': '手机号已存在'})
obj = UserModel.objects.create(
username=phone, last_login=datetime.now())
p = Userprofile.objects.create( p = Userprofile.objects.create(
user=obj, name=name, organization=o, admin_status=2) user=obj, name=name, organization=o, admin_status=2)
managers = Userprofile.level1_admin() managers = Userprofile.level1_admin()
@ -410,10 +410,10 @@ def media_admin_add(request):
send_tnps(phones, '审核', content) send_tnps(phones, '审核', content)
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( if UserModel.objects.filter(username=phone).exists():
username=phone, last_login=datetime.now())
if not created:
return JsonResponse({'status': 'error', 'message': '手机号已存在'}) return JsonResponse({'status': 'error', 'message': '手机号已存在'})
obj = UserModel.objects.create(
username=phone, last_login=datetime.now())
p = Userprofile.objects.create( p = Userprofile.objects.create(
user=obj, name=name, organization=o, admin_status=1) user=obj, name=name, organization=o, admin_status=1)
managers = Userprofile.level2_admin(o.cities) managers = Userprofile.level2_admin(o.cities)