修复误删用户问题

This commit is contained in:
zema1 2017-11-23 22:00:58 +08:00
parent a87d73393d
commit 4e80ac9492

View File

@ -120,8 +120,7 @@ class UserAdminAPI(APIView):
user = User.objects.get(id=user_id)
except User.DoesNotExist:
return f"User {user_id} does not exist"
profile = user.userprofile
if profile.submission_number:
if Submission.objects.filter(user_id=user_id).exists():
return f"Can't delete the user {user_id} as he/she has submissions"
user.delete()