mirror of
https://github.com/QingdaoU/OnlineJudge.git
synced 2025-11-04 14:49:58 +08:00
[Add] Forum Reply Delete
This commit is contained in:
parent
17530c4796
commit
8f15bc8639
@ -87,9 +87,13 @@ class ForumPostAPI(APIView):
|
||||
"""
|
||||
if request.GET.get("forumpost_id"):
|
||||
username = request.user.username
|
||||
user = User.objects.get(username=str(username), is_disabled=False)
|
||||
admin_type = UserProfileSerializer(user.userprofile, show_real_name=False).data["user"]["admin_type"]
|
||||
forumpost = ForumPost.objects.get(id=request.GET["forumpost_id"])
|
||||
if str(username) == str(forumpost.author):
|
||||
ForumPost.objects.filter(id=request.GET["forumpost_id"]).delete()
|
||||
elif admin_type == "Super Admin":
|
||||
ForumPost.objects.filter(id=request.GET["forumpost_id"]).delete()
|
||||
else:
|
||||
return self.error("Username doesn't match")
|
||||
return self.success()
|
||||
@ -143,8 +147,12 @@ class ForumReplyAPI(APIView):
|
||||
"""
|
||||
if request.GET.get("id"):
|
||||
username = request.user.username
|
||||
user = User.objects.get(username=str(username), is_disabled=False)
|
||||
admin_type = UserProfileSerializer(user.userprofile, show_real_name=False).data["user"]["admin_type"]
|
||||
forumreply = ForumReply.objects.get(id=request.GET["id"])
|
||||
if username == forumreply.author:
|
||||
if str(username) == str(forumreply.author):
|
||||
ForumReply.objects.filter(id=request.GET["id"]).delete()
|
||||
elif admin_type == "Super Admin":
|
||||
ForumReply.objects.filter(id=request.GET["id"]).delete()
|
||||
else:
|
||||
return self.error("Username doesn't match")
|
||||
|
||||
Loading…
Reference in New Issue
Block a user