Skip to content

Commit

Permalink
Merge pull request #239 from gcivil-nyu-org/migr_sarthak
Browse files Browse the repository at this point in the history
Fix Issue 210
  • Loading branch information
sarthakgoel1997 committed Apr 21, 2024
2 parents 21981eb + 5409525 commit 6011fda
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions healthScore/community_data.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from django.shortcuts import render, redirect, get_object_or_404
from django.contrib.auth.decorators import login_required
from django.http import JsonResponse

from .models import (
Post,
Expand Down Expand Up @@ -101,7 +102,12 @@ def create_comments(request, post_id):

@login_required(login_url="/")
def delete_comment(request, comment_id):
userID = request.user.id
comment = get_object_or_404(Comment, id=comment_id)

if comment.post.user.id != userID and comment.commenter.id != userID:
return JsonResponse({"error": "Unauthorized"}, status=401)

if request.method == "GET":
comment.delete()

Expand Down

0 comments on commit 6011fda

Please sign in to comment.