-
-
Notifications
You must be signed in to change notification settings - Fork 159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding post coments deletion feature at issue2 page #1470
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -2032,6 +2032,24 @@ def comment_on_issue(request, issue_pk): | |||
|
||||
return render(request, "comments2.html",context) | ||||
|
||||
def delete_comment(request): | ||||
issue = Issue.objects.get(pk=request.POST['issue_pk']) | ||||
if request.method == "POST": | ||||
all_comment = Comment.objects.filter(issue=issue) | ||||
print(request.POST['issue_pk']) | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm very sorry sir ,i didn't notice that |
||||
comment = Comment.objects.get(pk=int(request.POST['comment_pk'])) | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also add user to the query |
||||
try: | ||||
show = comment.parent.pk | ||||
except: | ||||
show = -1 | ||||
if request.user.username != comment.author: | ||||
return HttpResponse("Cannot delete this comment") | ||||
comment.delete() | ||||
context = { | ||||
"all_comment": Comment.objects.filter(issue__id=int(request.POST['issue_pk'])).order_by("-created_date"), | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reuse the query from above |
||||
"object": issue, | ||||
} | ||||
return render(request, "comments2.html", context) | ||||
|
||||
class CustomObtainAuthToken(ObtainAuthToken): | ||||
def post(self, request, *args, **kwargs): | ||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check this is an int