From 5d81a507c455d631b430f70b4670cb675a9e7157 Mon Sep 17 00:00:00 2001 From: anhkha2003 Date: Wed, 25 Oct 2023 02:13:51 -0500 Subject: [PATCH 1/3] Fix Comment bugs --- judge/comments.py | 8 +++++--- templates/comments/media-js.html | 3 +++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/judge/comments.py b/judge/comments.py index dde97a0..98434cf 100644 --- a/judge/comments.py +++ b/judge/comments.py @@ -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, diff --git a/templates/comments/media-js.html b/templates/comments/media-js.html index 862dbee..4c85ae4 100644 --- a/templates/comments/media-js.html +++ b/templates/comments/media-js.html @@ -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')); } }) } From c686abb222dfaffd77c47b318175e6421f20b426 Mon Sep 17 00:00:00 2001 From: anhkha2003 Date: Fri, 22 Dec 2023 23:23:56 -0600 Subject: [PATCH 2/3] Update Chat --- templates/chat/chat_js.html | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/templates/chat/chat_js.html b/templates/chat/chat_js.html index 78418c5..1c89800 100644 --- a/templates/chat/chat_js.html +++ b/templates/chat/chat_js.html @@ -219,7 +219,6 @@ if ($("#chat-input").val().trim()) { $('#chat-input-container').height('auto'); var body = $('#chat-input').val().trim(); - // body = body.split('\n').join('\n\n'); var message = { body: body, @@ -228,6 +227,7 @@ }; $('#chat-input').val(''); + $('#chat-input').css('height', '70%'); add_message_from_template(body, message.tmp_id); @@ -239,6 +239,8 @@ $('#empty_msg').hide(); $('#chat-input').focus(); }) + + } {% endif %} } From e2014a9c409333f9d181c69db7b9868f95354846 Mon Sep 17 00:00:00 2001 From: anhkha2003 Date: Fri, 22 Dec 2023 23:26:18 -0600 Subject: [PATCH 3/3] Remove empty lines --- templates/chat/chat_js.html | 2 -- 1 file changed, 2 deletions(-) diff --git a/templates/chat/chat_js.html b/templates/chat/chat_js.html index 1c89800..81fe1f9 100644 --- a/templates/chat/chat_js.html +++ b/templates/chat/chat_js.html @@ -239,8 +239,6 @@ $('#empty_msg').hide(); $('#chat-input').focus(); }) - - } {% endif %} }