Fix Comment bugs (#93)

This commit is contained in:
Phuoc Anh Kha Le 2023-10-25 02:19:05 -05:00 committed by GitHub
parent 93d032fc72
commit 3a7d4d8f0a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 3 deletions

View file

@ -144,14 +144,16 @@ class CommentedDetailView(TemplateResponseMixin, SingleObjectMixin, View):
def get(self, request, *args, **kwargs):
target_comment = None
self.object = self.get_object()
if "comment-id" in request.GET:
comment_id = int(request.GET["comment-id"])
try:
comment_id = int(request.GET["comment-id"])
comment_obj = Comment.objects.get(id=comment_id)
except Comment.DoesNotExist:
except (Comment.DoesNotExist, ValueError):
raise Http404
if comment_obj.linked_object != self.object:
raise Http404
target_comment = comment_obj.get_root()
self.object = self.get_object()
return self.render_to_response(
self.get_context_data(
object=self.object,

View file

@ -145,6 +145,8 @@
$comment_loading.hide();
var $comment = $("#comment-" + id + "-children");
$comment.append(data);
MathJax.typeset($('#comments')[0]);
register_time($('.time-with-rel'));
}
})
}
@ -187,6 +189,7 @@
$comment.append(data);
}
MathJax.typeset($('#comments')[0]);
register_time($('.time-with-rel'));
}
})
}