Skip to content

Commit

Permalink
feat(comment): add me.like in comment (#336)
Browse files Browse the repository at this point in the history
  • Loading branch information
Topology2333 authored Nov 20, 2023
1 parent 7683d2f commit c0e71a6
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions hinghwa-dict-backend/article/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,12 +304,22 @@ def put(self, request) -> JsonResponse:

class CommentDetail(View):
# AT0405 获取评论详情
def get(self, request, id) -> JsonResponse: # 注意没有使用request,位置也是需要保留着的
def get(self, request, id) -> JsonResponse:
try:
comment = Comment.objects.get(id=id)
except:
except Comment.DoesNotExist:
raise CommentNotFoundException(id)
return JsonResponse({"comment": comment_all(comment)}, status=200)

me = {"like": False}

# token = token_pass(request.headers)
user = request.user

# 是否是评论的作者,未添加

me["like"] = comment.like_users.filter(id=user.id).exists()

return JsonResponse({"comment": comment_all(comment), "me": me}, status=200)


class LikeComment(View):
Expand Down

0 comments on commit c0e71a6

Please sign in to comment.