-
Notifications
You must be signed in to change notification settings - Fork 9
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
feat(comment): add me.like in comment #336
Changes from all commits
21ab819
39ed02f
3187b2d
38180a7
858c082
851d673
a1ffe30
124bc72
f59a39e
fce79ab
48fbebf
d95b4ba
e8a06a9
297fa27
10e8554
1484805
439e313
d7fbff9
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 |
---|---|---|
|
@@ -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) | ||
|
||
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. 你可以用except,但是应该在这里就处理掉了 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.
好了、 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. 居然还在x |
||
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): | ||
|
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.
怎么还有try在最外面,受不了了