-
-
Notifications
You must be signed in to change notification settings - Fork 156
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
Conversation
Test comment |
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.
please close this if the other PR fixes it
website/views.py
Outdated
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 comment
The reason will be displayed to describe this comment to others. Learn more.
print(request.POST['issue_pk']) |
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.
I'm very sorry sir ,i didn't notice that
website/views.py
Outdated
@@ -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']) |
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
if request.method == "POST": | ||
all_comment = Comment.objects.filter(issue=issue) | ||
print(request.POST['issue_pk']) | ||
comment = Comment.objects.get(pk=int(request.POST['comment_pk'])) |
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.
Also add user to the query
website/views.py
Outdated
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 comment
The reason will be displayed to describe this comment to others. Learn more.
Reuse the query from above
Fixed issue #1469
Work:
2.create a function which return the comment data after delete the specific comment .(views.py --- at website folder)
3.Write some jQuery code for make the ajax call(comments2.html --- at templates folder)
screenshot :