From 57ded6ff5ecf99951f024e171ad44f433d51138a Mon Sep 17 00:00:00 2001 From: cuom1999 Date: Mon, 22 May 2023 23:11:40 +0700 Subject: [PATCH] Fix some bugs for new comment --- judge/comments.py | 87 +++++----- judge/views/comment.py | 48 +++--- locale/vi/LC_MESSAGES/django.po | 127 +++++++-------- locale/vi/LC_MESSAGES/dmoj-user.po | 9 +- resources/comments.scss | 4 + templates/comments/content-list.html | 234 +++++++++++++-------------- templates/comments/list.html | 135 +--------------- templates/comments/media-js.html | 26 ++- 8 files changed, 267 insertions(+), 403 deletions(-) diff --git a/judge/comments.py b/judge/comments.py index 2a2f515..5a38380 100644 --- a/judge/comments.py +++ b/judge/comments.py @@ -28,6 +28,9 @@ from judge.widgets import HeavyPreviewPageDownWidget from judge.jinja2.reference import get_user_from_text +DEFAULT_OFFSET = 10 + + def add_mention_notifications(comment): user_referred = get_user_from_text(comment.body).exclude(id=comment.author.id) for user in user_referred: @@ -152,92 +155,90 @@ class CommentedDetailView(TemplateResponseMixin, SingleObjectMixin, View): return self.render_to_response(context) def get(self, request, *args, **kwargs): - pre_query = None + target_comment = None if "comment-id" in request.GET: comment_id = int(request.GET["comment-id"]) try: - comment_obj = Comment.objects.get(pk=comment_id) + comment_obj = Comment.objects.get(id=comment_id) except Comment.DoesNotExist: raise Http404 - pre_query = comment_obj - while comment_obj is not None: - pre_query = comment_obj - comment_obj = comment_obj.parent + target_comment = comment_obj.get_root() self.object = self.get_object() return self.render_to_response( self.get_context_data( object=self.object, - pre_query=pre_query, + target_comment=target_comment, comment_form=CommentForm(request, initial={"parent": None}), ) ) - def get_context_data(self, pre_query=None, **kwargs): - context = super(CommentedDetailView, self).get_context_data(**kwargs) - queryset = self.object.comments - queryset = queryset.filter(parent=None, hidden=False) - queryset_all = None - comment_count = len(queryset) - context["comment_remove"] = -1 - if (pre_query != None): - comment_remove = pre_query.id - queryset_all = pre_query.get_descendants(include_self=True) - queryset_all = ( - queryset_all.select_related("author__user") + def _get_queryset(self, target_comment): + if target_comment != None: + queryset = target_comment.get_descendants(include_self=True) + queryset = ( + queryset.select_related("author__user") .filter(hidden=False) .defer("author__about") - .annotate(revisions=Count("versions", distinct=True)) + .annotate( + revisions=Count("versions", distinct=True) + ) ) - context["comment_remove"] = comment_remove else: + queryset = self.object.comments + queryset = queryset.filter(parent=None, hidden=False) queryset = ( queryset.select_related("author__user") .defer("author__about") .filter(hidden=False) .annotate( - count_replies=Count("replies", distinct=True), + count_replies=Count("replies", distinct=True), revisions=Count("versions", distinct=True), - )[:10] + )[:DEFAULT_OFFSET] ) - + if self.request.user.is_authenticated: profile = self.request.profile - if (pre_query != None): - queryset_all = queryset_all.annotate( - my_vote=FilteredRelation( - "votes", condition=Q(votes__voter_id=profile.id) - ), - ).annotate(vote_score=Coalesce(F("my_vote__score"), Value(0))) - else: - queryset = queryset.annotate( - my_vote=FilteredRelation( - "votes", condition=Q(votes__voter_id=profile.id) - ), - ).annotate(vote_score=Coalesce(F("my_vote__score"), Value(0))) + queryset = queryset.annotate( + my_vote=FilteredRelation( + "votes", condition=Q(votes__voter_id=profile.id) + ), + ).annotate(vote_score=Coalesce(F("my_vote__score"), Value(0))) + return queryset + + def get_context_data(self, target_comment=None, **kwargs): + context = super(CommentedDetailView, self).get_context_data(**kwargs) + queryset = self._get_queryset(target_comment) + comment_count = self.object.comments.filter(parent=None, hidden=False).count() + context["target_comment"] = -1 + if (target_comment != None): + context["target_comment"] = target_comment.id + + if self.request.user.is_authenticated: context["is_new_user"] = ( not self.request.user.is_staff and not profile.submission_set.filter( points=F("problem__points") ).exists() ) - + context["has_comments"] = queryset.exists() context["comment_lock"] = self.is_comment_locked() context["comment_list"] = queryset - context["comment_all_list"] = queryset_all context["vote_hide_threshold"] = settings.DMOJ_COMMENT_VOTE_HIDE_THRESHOLD if queryset.exists(): context["comment_root_id"] = queryset[0].id else: context["comment_root_id"] = 0 - context["comment_parrent_none"] = 1 - if (pre_query != None): - context["offset"] = 1 + context["comment_parent_none"] = 1 + if target_comment != None: + context["offset"] = 0 + context["comment_more"] = comment_count - 1 else: - context["offset"] = 10 + context["offset"] = DEFAULT_OFFSET + context["comment_more"] = comment_count - DEFAULT_OFFSET - context["limit"] = 10 + context["limit"] = DEFAULT_OFFSET context["comment_count"] = comment_count return context diff --git a/judge/views/comment.py b/judge/views/comment.py index abacb52..3c88923 100644 --- a/judge/views/comment.py +++ b/judge/views/comment.py @@ -110,46 +110,52 @@ def vote_comment(request, delta): def upvote_comment(request): return vote_comment(request, 1) + def downvote_comment(request): return vote_comment(request, -1) + def get_comments(request, limit=10): try: comment_id = int(request.GET["id"]) - parrent_none = int(request.GET["parrent_none"]) + parent_none = int(request.GET["parent_none"]) except ValueError: return HttpResponseBadRequest() else: if comment_id and not Comment.objects.filter(id=comment_id).exists(): raise Http404() + offset = 0 if "offset" in request.GET: offset = int(request.GET["offset"]) - comment_remove = -1 - if "comment_remove" in request.GET: - comment_remove = int(request.GET["comment_remove"]) + + target_comment = -1 + if "target_comment" in request.GET: + target_comment = int(request.GET["target_comment"]) + comment_root_id = 0 - if (comment_id): + + if comment_id: comment_obj = Comment.objects.get(pk=comment_id) comment_root_id = comment_obj.id else: comment_obj = None + queryset = comment_obj.linked_object.comments - if parrent_none: + if parent_none: queryset = queryset.filter(parent=None, hidden=False) - if (comment_remove != -1): - queryset.get(pk=comment_remove).delete() + queryset = queryset.exclude(pk=target_comment) else: queryset = queryset.filter(parent=comment_obj, hidden=False) comment_count = len(queryset) queryset = ( - queryset.select_related("author__user") - .defer("author__about") - .annotate( - count_replies=Count("replies", distinct=True), - revisions=Count("versions", distinct=True), - )[offset:offset+limit] - ) + queryset.select_related("author__user") + .defer("author__about") + .annotate( + count_replies=Count("replies", distinct=True), + revisions=Count("versions", distinct=True), + )[offset:offset+limit] + ) if request.user.is_authenticated: profile = request.profile queryset = queryset.annotate( @@ -158,6 +164,8 @@ def get_comments(request, limit=10): ), ).annotate(vote_score=Coalesce(F("my_vote__score"), Value(0))) + new_offset = offset + min(len(queryset), limit) + comment_html = loader.render_to_string( "comments/content-list.html", { @@ -166,22 +174,26 @@ def get_comments(request, limit=10): "comment_list": queryset, "vote_hide_threshold" : settings.DMOJ_COMMENT_VOTE_HIDE_THRESHOLD, "perms": PermWrapper(request.user), - "offset": offset + min(len(queryset), limit), + "offset": new_offset, "limit": limit, "comment_count": comment_count, - "comment_parrent_none": parrent_none, - "comment_remove": comment_remove, + "comment_parent_none": parent_none, + "target_comment": target_comment, + "comment_more": comment_count - new_offset } ) return HttpResponse(comment_html) + def get_show_more(request): return get_comments(request) + def get_replies(request): return get_comments(request) + class CommentMixin(object): model = Comment pk_url_kwarg = "id" diff --git a/locale/vi/LC_MESSAGES/django.po b/locale/vi/LC_MESSAGES/django.po index 268b457..b4bcfb1 100644 --- a/locale/vi/LC_MESSAGES/django.po +++ b/locale/vi/LC_MESSAGES/django.po @@ -2,7 +2,7 @@ msgid "" msgstr "" "Project-Id-Version: lqdoj2\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2023-05-16 16:17+0700\n" +"POT-Creation-Date: 2023-05-22 23:06+0700\n" "PO-Revision-Date: 2021-07-20 03:44\n" "Last-Translator: Icyene\n" "Language-Team: Vietnamese\n" @@ -41,19 +41,19 @@ msgstr "xem lần cuối" msgid "LQDOJ Chat" msgstr "" -#: dmoj/settings.py:365 +#: dmoj/settings.py:363 msgid "Vietnamese" msgstr "Tiếng Việt" -#: dmoj/settings.py:366 +#: dmoj/settings.py:364 msgid "English" msgstr "" -#: dmoj/urls.py:136 +#: dmoj/urls.py:135 msgid "Login" msgstr "Đăng nhập" -#: dmoj/urls.py:214 templates/base.html:209 +#: dmoj/urls.py:212 templates/base.html:209 #: templates/organization/org-left-sidebar.html:2 msgid "Home" msgstr "Trang chủ" @@ -426,20 +426,20 @@ msgstr "Dạng" msgid "Online Judge" msgstr "" -#: judge/comments.py:61 +#: judge/comments.py:64 msgid "Comment body" msgstr "Nội dung bình luận" -#: judge/comments.py:67 judge/views/ticket.py:78 +#: judge/comments.py:70 judge/views/ticket.py:78 msgid "Your part is silent, little toad." msgstr "Bạn không được phép bình luận." -#: judge/comments.py:76 templates/comments/list.html:17 +#: judge/comments.py:79 templates/comments/list.html:17 msgid "" "You need to have solved at least one problem before your voice can be heard." msgstr "Bạn phải giải ít nhất một bài trước khi được phép bình luận." -#: judge/comments.py:125 +#: judge/comments.py:128 msgid "Posted comment" msgstr "Bình luận đã đăng" @@ -533,7 +533,7 @@ msgid "N j, Y, g:i a" msgstr "g:i a j b, Y" #: judge/jinja2/datetime.py:26 templates/chat/message.html:13 -#: templates/comments/content-list.html:35 templates/comments/list.html:77 +#: templates/comments/content-list.html:36 #, python-brace-format msgid "{time}" msgstr "{time}" @@ -2514,11 +2514,11 @@ msgstr "Tính lại điểm kỳ thi" msgid "Running MOSS" msgstr "Đang chạy MOSS" -#: judge/tasks/submission.py:47 +#: judge/tasks/submission.py:49 msgid "Modifying submissions" msgstr "Chỉnh sửa bài nộp" -#: judge/tasks/submission.py:67 +#: judge/tasks/submission.py:69 msgid "Recalculating user points" msgstr "Tính lại điểm người dùng" @@ -2658,12 +2658,12 @@ msgstr "Bạn phải giải ít nhất 1 bài trước khi được vote." msgid "You already voted." msgstr "Bạn đã vote." -#: judge/views/comment.py:243 judge/views/organization.py:817 +#: judge/views/comment.py:255 judge/views/organization.py:817 #: judge/views/organization.py:963 judge/views/organization.py:1128 msgid "Edited from site" msgstr "Chỉnh sửa từ web" -#: judge/views/comment.py:264 +#: judge/views/comment.py:276 msgid "Editing comment" msgstr "Chỉnh sửa bình luận" @@ -3288,8 +3288,8 @@ msgstr "Phải qua một kỳ thi" #: judge/views/submission.py:903 #, python-brace-format msgid "" -"{0}'s submissions for {2} in {4}" +"{0}'s submissions for {2} in {4}" msgstr "" "Các bài nộp của {0} cho {2} trong {4}" @@ -3502,7 +3502,7 @@ msgid "Profile" msgstr "Trang cá nhân" #: templates/base.html:276 templates/chat/chat.html:21 -#: templates/comments/content-list.html:80 templates/comments/list.html:126 +#: templates/comments/content-list.html:81 #: templates/contest/contest-list-tabs.html:4 #: templates/contest/ranking-table.html:47 templates/internal/problem.html:57 #: templates/organization/org-left-sidebar.html:12 @@ -3559,12 +3559,12 @@ msgstr "" msgid " posted on %(time)s" msgstr "đã đăng vào %(time)s" -#: templates/blog/blog.html:31 templates/comments/content-list.html:61 -#: templates/comments/content-list.html:75 templates/comments/list.html:105 -#: templates/comments/list.html:120 templates/contest/contest-tabs.html:35 -#: templates/contest/list.html:124 templates/contest/tag-title.html:9 -#: templates/flatpages/admin_link.html:3 templates/license.html:10 -#: templates/problem/editorial.html:15 templates/problem/feed/problems.html:50 +#: templates/blog/blog.html:31 templates/comments/content-list.html:62 +#: templates/comments/content-list.html:76 +#: templates/contest/contest-tabs.html:35 templates/contest/list.html:124 +#: templates/contest/tag-title.html:9 templates/flatpages/admin_link.html:3 +#: templates/license.html:10 templates/problem/editorial.html:15 +#: templates/problem/feed/problems.html:50 msgid "Edit" msgstr "Chỉnh sửa" @@ -3699,66 +3699,54 @@ msgstr "Tắt thông báo" msgid "users are online" msgstr "người đang trực tuyến" -#: templates/comments/content-list.html:13 #: templates/comments/content-list.html:14 -#: templates/comments/content-list.html:22 -#: templates/comments/content-list.html:23 templates/comments/list.html:55 -#: templates/comments/list.html:64 +#: templates/comments/content-list.html:15 +#: templates/comments/content-list.html:23 +#: templates/comments/content-list.html:24 msgid "Please login to vote" msgstr "Đăng nhập để vote" -#: templates/comments/content-list.html:43 templates/comments/list.html:86 +#: templates/comments/content-list.html:44 #, python-format msgid "edit %(edits)s" msgstr "chỉnh sửa %(edits)s" -#: templates/comments/content-list.html:45 templates/comments/list.html:88 -#: templates/comments/media-js.html:96 +#: templates/comments/content-list.html:46 templates/comments/media-js.html:96 msgid "edited" msgstr "đã chỉnh sửa" -#: templates/comments/content-list.html:54 templates/comments/list.html:97 -#: templates/notification/list.html:14 +#: templates/comments/content-list.html:55 templates/notification/list.html:14 msgid "Link" msgstr "Link" -#: templates/comments/content-list.html:65 -#: templates/comments/content-list.html:71 templates/comments/list.html:110 -#: templates/comments/list.html:117 +#: templates/comments/content-list.html:66 +#: templates/comments/content-list.html:72 msgid "Reply" msgstr "Phản hồi" -#: templates/comments/content-list.html:78 templates/comments/list.html:123 +#: templates/comments/content-list.html:79 msgid "Hide" msgstr "Ẩn" -#: templates/comments/content-list.html:92 +#: templates/comments/content-list.html:94 #, fuzzy, python-format #| msgid "" -#| "This comment is hidden due to too much negative feedback. Click here to view it." +#| "This comment is hidden due to too much negative feedback. Click here to view it." msgid "" "This comment is hidden due to too much negative feedback. Click here to view it." +" href=\"javascript:comment_show_content(%(id)s)\">here to " +"view it." msgstr "" "Bình luận bị ẩn vì nhiều phản hồi tiêu cực. Nhấp vào đây để mở." -#: templates/comments/content-list.html:107 +#: templates/comments/content-list.html:109 msgid "replies" msgstr "phản hồi" -#: templates/comments/content-list.html:114 -msgid "reply" -msgstr "phản hồi" - -#: templates/comments/content-list.html:130 templates/comments/list.html:160 -msgid "comment more" -msgstr "bình luận nữa" - -#: templates/comments/content-list.html:137 templates/comments/list.html:168 -msgid "comments more" +#: templates/comments/content-list.html:129 +msgid "more comments" msgstr "bình luận nữa" #: templates/comments/list.html:6 @@ -3777,20 +3765,11 @@ msgstr "Nội dung không hợp lệ." msgid "Post!" msgstr "Đăng!" -#: templates/comments/list.html:138 -#, python-format -msgid "" -"This comment is hidden due to too much negative feedback. Click here to view it." -msgstr "" -"Bình luận bị ẩn vì nhiều phản hồi tiêu cực. Nhấp vào đây để mở." - -#: templates/comments/list.html:177 +#: templates/comments/list.html:44 msgid "There are no comments at the moment." msgstr "Không có bình luận nào." -#: templates/comments/list.html:182 +#: templates/comments/list.html:49 msgid "Comments are disabled on this page." msgstr "Bình luận bị tắt trong trang này." @@ -3918,8 +3897,8 @@ msgstr "G:i T, j F, Y" #: templates/contest/contest-datetime.html:39 #, python-format msgid "" -"%(time_limit)s window between %(start_time)s and " -"%(end_time)s" +"%(time_limit)s window between %(start_time)s and " +"%(end_time)s" msgstr "" "Kéo dài %(time_limit)s từ %(start_time)s đến %(end_time)s" @@ -5752,6 +5731,22 @@ msgstr "Thông tin" msgid "Check all" msgstr "Chọn tất cả" +#~ msgid "reply" +#~ msgstr "phản hồi" + +#~ msgid "comment more" +#~ msgstr "bình luận nữa" + +#~ msgid "comments more" +#~ msgstr "bình luận nữa" + +#~ msgid "" +#~ "This comment is hidden due to too much negative feedback. Click here to view it." +#~ msgstr "" +#~ "Bình luận bị ẩn vì nhiều phản hồi tiêu cực. Nhấp vào đây để mở." + #, fuzzy #~| msgid "short name" #~ msgid "first name" @@ -5804,7 +5799,6 @@ msgstr "Chọn tất cả" #~ msgid "Django administration" #~ msgstr "Quản trị viên Django" -#, python-format #~ msgid "" #~ "Please enter the correct %(username)s and password for an admin account. " #~ "Note that both fields may be case-sensitive." @@ -5812,7 +5806,6 @@ msgstr "Chọn tất cả" #~ "Hãy nhập %(username)s và mật khẩu hợp lệ cho tài khoản quản trị. Chú ý cả " #~ "hai trường có phân biệt chữ Hoa-thường." -#, python-format #~ msgid "" #~ "Please enter the correct %(username)s and password for an user account. " #~ "Note that both fields may be case-sensitive." diff --git a/locale/vi/LC_MESSAGES/dmoj-user.po b/locale/vi/LC_MESSAGES/dmoj-user.po index c65744d..ffd36e9 100644 --- a/locale/vi/LC_MESSAGES/dmoj-user.po +++ b/locale/vi/LC_MESSAGES/dmoj-user.po @@ -33,6 +33,9 @@ msgstr "Đề xuất bài tập" msgid "TanKhoa" msgstr "Tân Khoa" +msgid "Name" +msgstr "Đăng ký tên" + msgid "Report" msgstr "Báo cáo" @@ -342,9 +345,6 @@ msgstr "" msgid "ltt" msgstr "" -msgid "Luyện tập" -msgstr "" - msgid "manacher" msgstr "" @@ -593,6 +593,3 @@ msgstr "" msgid "z-function" msgstr "" - -#~ msgid "Name" -#~ msgstr "Đăng ký tên" diff --git a/resources/comments.scss b/resources/comments.scss index da828b4..c606f26 100644 --- a/resources/comments.scss +++ b/resources/comments.scss @@ -306,6 +306,10 @@ a { } } +.show_more_comment { + margin-left: -20px; +} + @media (max-width: 799px) { .hide_texts_on_mobile .actionbar-text { display: none; diff --git a/templates/comments/content-list.html b/templates/comments/content-list.html index 0c3408d..863839f 100644 --- a/templates/comments/content-list.html +++ b/templates/comments/content-list.html @@ -1,139 +1,131 @@ {% set logged_in = request.user.is_authenticated %} {% set profile = request.profile if logged_in else None %} + {% for node in mptt_tree(comment_list) recursive %}
  • -
    -
    -
    - {% if logged_in %} - + data-revision-ajax="{{ url('comment_revision_ajax', node.id) }}" class="comment"> +
    +
    +
    + {% if logged_in %} + + {% else %} + + {% endif %} +
    +
    {{ node.score }}
    + {% if logged_in %} + + {% else %} + + {% endif %} +
    +
    +
    +
    + {% with author=node.author, user=node.author.user %} + + + + {% endwith %} + {{ link_user(node.author) }},  + {{ relative_time(node.time, abs=_('{time}'), rel=_('{time}')) }} + + + {% if node.revisions > 1 %} + + + + {% if node.revisions > 2 %} + {% trans edits=node.revisions - 1 %}edit {{ edits }}{% endtrans %} {% else %} - + {{ _('edited') }} {% endif %} -
    -
    {{ node.score }}
    - {% if logged_in %} - - {% else %} - - {% endif %} -
    -
    -
    -
    - {% with author=node.author, user=node.author.user %} - - - - {% endwith %} - {{ link_user(node.author) }},  - {{ relative_time(node.time, abs=_('{time}'), rel=_('{time}')) }} - - - {% if node.revisions > 1 %} - - - - {% if node.revisions > 2 %} - {% trans edits=node.revisions - 1 %}edit {{ edits }}{% endtrans %} - {% else %} - {{ _('edited') }} - {% endif %} - - - - {% else %} - - {% endif %} - - - - {% if logged_in and not comment_lock %} - {% set can_edit = node.author.id == profile.id and not profile.mute %} - {% if can_edit %} - - - - {% else %} - - - - {% endif %} - {% if perms.judge.change_comment %} - {% if can_edit %} - - {% else %} - - {% endif %} - - - {% endif %} - {% endif %} - -
    -
    - - {% if node.score <= vote_hide_threshold %}
    -

    - {% trans id=node.id %}This comment is hidden due to too much negative feedback. Click here to view it.{% endtrans %} -

    -
    + + + + {% else %} + {% endif %} + + + + {% if logged_in and not comment_lock %} + {% set can_edit = node.author.id == profile.id and not profile.mute %} + {% if can_edit %} + + + + {% else %} + + + + {% endif %} + {% if perms.judge.change_comment %} + {% if can_edit %} + + {% else %} + + {% endif %} + + + {% endif %} + {% endif %} + +
    +
    + + {% if node.score <= vote_hide_threshold %} +
    +

    + {% trans id=node.id %}This comment is hidden due to too much negative feedback. Click here to view it.{% endtrans %} +

    +
    + {% endif %} +
    -
    +
    - {% if node.count_replies > 1 %} + {% if node.count_replies %} - - - - - {{ node.count_replies }} {{ _('replies') }} - {% elif node.count_replies %} - - - - - - {{ node.count_replies }} {{ _('reply') }} - {% endif %} + + + + + {{ node.count_replies }} {{ _('replies') if node.count_replies > 1 else _('reply') }} + + {% endif %}
  • -
    + {% with children=node.get_children() %} + {% if children %} +
      {{ loop(children) }}
    + {% else %} +
      + {% endif %} + {% endwith %} {% endfor %} - - -{% set comment_more = comment_count - offset %} -{% if comment_more == 1 %} - +{% if comment_more > 0 %} + - - + + - {{ comment_count - offset }} {{ _('comment more') }} -{% elif comment_more > 1 %} - - - - - - {{ comment_count - offset }} {{ _('comments more') }} + {{ comment_more }} {{ _('more comments') if comment_more > 1 else _('more comment') }} + {% endif %} - diff --git a/templates/comments/list.html b/templates/comments/list.html index 9977eb5..d561210 100644 --- a/templates/comments/list.html +++ b/templates/comments/list.html @@ -36,142 +36,9 @@ {% endif %} {% endif %} - {% if has_comments or comment_all_list %} + {% if has_comments %}
        - {% set logged_in = request.user.is_authenticated %} - {% set profile = request.profile if logged_in else None %} - {% if comment_all_list %} - {% for node in mptt_tree(comment_all_list) recursive %} -
      • -
        -
        -
        - {% if logged_in %} - - {% else %} - - {% endif %} -
        -
        {{ node.score }}
        - {% if logged_in %} - - {% else %} - - {% endif %} -
        -
        -
        -
        - {% with author=node.author, user=node.author.user %} - - - - {% endwith %} - {{ link_user(node.author) }},  - {{ relative_time(node.time, abs=_('{time}'), rel=_('{time}')) }} - - - {% if node.revisions > 1 %} - - - - {% if node.revisions > 2 %} - {% trans edits=node.revisions - 1 %}edit {{ edits }}{% endtrans %} - {% else %} - {{ _('edited') }} - {% endif %} - - - - {% else %} - - {% endif %} - - - - {% if logged_in and not comment_lock %} - {% set can_edit = node.author.id == profile.id and not profile.mute %} - {% if can_edit %} - - - - {% else %} - - - - {% endif %} - {% if perms.judge.change_comment %} - {% if can_edit %} - - {% else %} - - {% endif %} - - - {% endif %} - {% endif %} - -
        -
        - - {% if node.score <= vote_hide_threshold %} -
        -

        - {% trans id=node.id %}This comment is hidden due to too much negative feedback. Click here to view it.{% endtrans %} -

        -
        - {% endif %} -
        -
        -
        -
      • - - {% with children=node.get_children() %} - {% if children %} -
          {{ loop(children) }}
        - {% endif %} - {% endwith %} - {% endfor %} - {% set comment_more = comment_count - offset %} - {% if comment_more == 1 %} - - - - - - {{ comment_count - offset }} {{ _('comment more') }} - - {% elif comment_more > 1 %} - - - - - - {{ comment_count - offset }} {{ _('comments more') }} - - {% endif %} - {% else %} {% include "comments/content-list.html" %} - {% endif %} -
      {% elif not comment_lock %}

      {{ _('There are no comments at the moment.') }}

      diff --git a/templates/comments/media-js.html b/templates/comments/media-js.html index 131d040..31a7862 100644 --- a/templates/comments/media-js.html +++ b/templates/comments/media-js.html @@ -121,24 +121,23 @@ } const queryString = window.location.search; const urlParams = new URLSearchParams(queryString); - const comment_remove = urlParams.get('comment-id'); - console.log(comment_remove); + const target_comment = urlParams.get('comment-id'); - window.comment_get_replies = function (id, parrent_none) { + window.comment_get_replies = function (id, parent_none) { var $comment_show_btn = $("#comment-" + id + " .show_more_reply"); $comment_show_btn.hide(); var $comment = $("#comment-" + id + "-children"); $comment.append("

      Loading...

      "); - ajax_get_reply('{{ url('comment_get_replies') }}', id, parrent_none); + ajax_get_reply('{{ url('comment_get_replies') }}', id, parent_none); } - function ajax_get_reply(url, id, parrent_none) { + function ajax_get_reply(url, id, parent_none) { return $.ajax({ url: url, type: 'GET', data: { id: id, - parrent_none: parrent_none, + parent_none: parent_none, }, success: function(data) { var $comment_loading = $("#comment-" + id + "-children .loading"); @@ -149,9 +148,8 @@ }) } - window.comment_show_more = function (id, parrent_none, offset, comment_remove) { - console.log(parrent_none) - if (parrent_none == 1) { + window.comment_show_more = function (id, parent_none, offset, target_comment) { + if (parent_none == 1) { var $comment_show_btn = $("#comment-0" + " .show_more_comment"); $comment_show_btn.hide(); var $comment = $("#comment-0"); @@ -162,21 +160,21 @@ var $comment = $("#comment-" + id + "-children"); $comment.append("

      Loading...

      "); } - ajax_comment_show_more('{{ url('comment_show_more') }}', id, parrent_none, offset, comment_remove); + ajax_comment_show_more('{{ url('comment_show_more') }}', id, parent_none, offset, target_comment); } - function ajax_comment_show_more(url, id, parrent_none, offset, comment_remove) { + function ajax_comment_show_more(url, id, parent_none, offset, target_comment) { return $.ajax({ url: url, type: 'GET', data: { id: id, - parrent_none: parrent_none, + parent_none: parent_none, offset: offset, - comment_remove: comment_remove, + target_comment: target_comment, }, success: function(data) { - if (parrent_none == 1) { + if (parent_none == 1) { var $comment_loading = $("#comment-0" + " .loading"); $comment_loading.hide(); var $comment = $("#comment-0");