change admin
This commit is contained in:
parent
f12fe00766
commit
0426ea726d
Binary file not shown.
|
@ -312,7 +312,6 @@ def media_admin_change(request):
|
||||||
if request.method == 'GET':
|
if request.method == 'GET':
|
||||||
return HttpResponse(status=405)
|
return HttpResponse(status=405)
|
||||||
id = request.POST.get('id')
|
id = request.POST.get('id')
|
||||||
print(id)
|
|
||||||
if not id:
|
if not id:
|
||||||
return JsonResponse({'status': 'error', 'message': '参数错误'})
|
return JsonResponse({'status': 'error', 'message': '参数错误'})
|
||||||
name = request.POST.get('name')
|
name = request.POST.get('name')
|
||||||
|
@ -323,11 +322,16 @@ def media_admin_change(request):
|
||||||
return JsonResponse({'status': 'error', 'message': '手机号不能为空'})
|
return JsonResponse({'status': 'error', 'message': '手机号不能为空'})
|
||||||
u = request.user
|
u = request.user
|
||||||
operator = Userprofile.objects.filter(user=u).first()
|
operator = Userprofile.objects.filter(user=u).first()
|
||||||
profile = Userprofile.objects.filter(user_id=id).first()
|
|
||||||
o = profile.organization
|
|
||||||
UserModel = get_user_model()
|
UserModel = get_user_model()
|
||||||
|
changing_user = UserModel.objects.get(id=id)
|
||||||
|
profile = changing_user.userprofile_set.first()
|
||||||
|
o = profile.organization
|
||||||
|
|
||||||
if o.is_direct(): # 如果是省直
|
if o.is_direct(): # 如果是省直
|
||||||
|
if changing_user.username == phone: #修改名字
|
||||||
|
profile.name = name
|
||||||
|
profile.save()
|
||||||
|
else:
|
||||||
obj, created = UserModel.objects.get_or_create(
|
obj, created = UserModel.objects.get_or_create(
|
||||||
username=phone)
|
username=phone)
|
||||||
if not created:
|
if not created:
|
||||||
|
@ -345,6 +349,10 @@ def media_admin_change(request):
|
||||||
a.user.id, content, 'dashboard', 'Userprofile', 'admin_status', o.id, '3', '0')
|
a.user.id, content, 'dashboard', 'Userprofile', 'admin_status', o.id, '3', '0')
|
||||||
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:
|
||||||
|
if changing_user.username == phone: #修改名字
|
||||||
|
profile.name = name
|
||||||
|
profile.save()
|
||||||
else:
|
else:
|
||||||
obj, created = UserModel.objects.get_or_create(
|
obj, created = UserModel.objects.get_or_create(
|
||||||
username=phone)
|
username=phone)
|
||||||
|
@ -387,14 +395,11 @@ def media_admin_add(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:
|
||||||
|
return JsonResponse({'status': 'error', 'message': '手机号已存在'})
|
||||||
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)
|
||||||
else:
|
|
||||||
p = Userprofile.objects.filter(user=obj).first()
|
|
||||||
p.admin_status = 2
|
|
||||||
p.save()
|
|
||||||
managers = Userprofile.level1_admin()
|
managers = Userprofile.level1_admin()
|
||||||
content = '%s申请添加管理员,请审核' % (operator,)
|
content = '%s申请添加管理员,请审核' % (operator,)
|
||||||
phones = []
|
phones = []
|
||||||
|
@ -407,14 +412,10 @@ def media_admin_add(request):
|
||||||
else:
|
else:
|
||||||
obj, created = UserModel.objects.get_or_create(
|
obj, created = UserModel.objects.get_or_create(
|
||||||
username=phone, last_login=datetime.now())
|
username=phone, last_login=datetime.now())
|
||||||
if created:
|
if not created:
|
||||||
|
return JsonResponse({'status': 'error', 'message': '手机号已存在'})
|
||||||
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)
|
||||||
else:
|
|
||||||
p = Userprofile.objects.filter(user=obj).first()
|
|
||||||
p.admin_status = 1
|
|
||||||
p.save()
|
|
||||||
|
|
||||||
managers = Userprofile.level2_admin(o.cities)
|
managers = Userprofile.level2_admin(o.cities)
|
||||||
content = '%s申请添加管理员,请审核' % (operator,)
|
content = '%s申请添加管理员,请审核' % (operator,)
|
||||||
phones = []
|
phones = []
|
||||||
|
|
Loading…
Reference in New Issue