Skip to content
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

Closed
wants to merge 3 commits into from

Conversation

JisanAR03
Copy link
Contributor

@JisanAR03 JisanAR03 commented Oct 11, 2023

Fixed issue #1469
Work:

  1. create a path for call the deletion request.(urls.py --- at website folder)
    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 :
image

@DonnieBLT
Copy link
Collaborator

Test comment

Copy link
Collaborator

@DonnieBLT DonnieBLT left a 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'])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
print(request.POST['issue_pk'])

Copy link
Contributor Author

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'])
Copy link
Collaborator

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']))
Copy link
Collaborator

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"),
Copy link
Collaborator

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

@JisanAR03 JisanAR03 closed this Oct 21, 2023
@JisanAR03 JisanAR03 deleted the issue-#1469 branch October 21, 2023 11:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants