删除用户时转移其协作文档给文集拥有者

This commit is contained in:
yangjian 2020-12-04 22:23:48 +08:00
parent 13101b221c
commit 10af0231de
2 changed files with 11 additions and 3 deletions

View File

@ -347,8 +347,15 @@ def admin_change_pwd(request):
def admin_del_user(request):
if request.method == 'POST':
try:
user_id = request.POST.get('user_id',None)
user = User.objects.get(id=int(user_id))
user_id = request.POST.get('user_id',None) # 获取用户ID
user = User.objects.get(id=int(user_id)) # 获取用户
colloas = ProjectCollaborator.objects.filter(user=user) # 获取参与协作的文集
# 遍历用户参与协作的文集
for colloa in colloas:
# 查询出用户协作创建的文档,修改作者为文集所有者
Doc.objects.filter(
top_doc=colloa.project.id,create_user=user
).update(create_user=colloa.project.create_user)
user.delete()
return JsonResponse({'status':True,'data':'删除成功'})
except Exception as e:
@ -623,6 +630,7 @@ def admin_register_code(request):
else:
return JsonResponse({'status': False,'data':'方法错误'})
# 普通用户修改密码
@login_required()
@logger.catch()

View File

@ -194,7 +194,7 @@
title:'删除用户',
area:'300px;',
id:'delPro',//配置ID
content:'<div style="margin-left:10px;">警告:此操作将删除用户'+username+'及其所有文档!</div>',
content:'<div style="margin-left:10px;">警告:此操作将删除用户'+username+'及其文集文档!协作文档将转移给文集所有者</div>',
btn:['确定','取消'], //添加按钮
btnAlign:'c', //按钮居中
yes:function (index,layero) {