From 1056a470b048cb36aff6bd7b9ea1f3ebc1d909c5 Mon Sep 17 00:00:00 2001 From: "Dung T.Bui" Date: Mon, 22 May 2023 20:52:18 +0700 Subject: [PATCH] Change comment style (#70) --- dmoj/urls.py | 2 + judge/comments.py | 85 ++- judge/models/comment.py | 12 +- judge/views/comment.py | 84 ++- locale/vi/LC_MESSAGES/django.po | 527 +++++++++--------- locale/vi/LC_MESSAGES/dmoj-user.po | 9 +- make_style.sh | 0 manage.py | 0 resources/bootstrap/bootstrap.min.css | 0 resources/comments.scss | 22 + .../placeholders/not_available-generic.png | Bin .../placeholders/waiting-generic.png | Bin resources/fontawesome/fontawesome.css | 0 resources/icons/android-chrome-512x512.png | Bin resources/icons/logo.png | Bin templates/actionbar/list.html | 2 +- templates/comments/content-list.html | 139 +++++ templates/comments/list.html | 33 +- templates/comments/media-js.html | 71 +++ 19 files changed, 680 insertions(+), 306 deletions(-) mode change 100755 => 100644 make_style.sh mode change 100755 => 100644 manage.py mode change 100755 => 100644 resources/bootstrap/bootstrap.min.css mode change 100755 => 100644 resources/fine-uploader/placeholders/not_available-generic.png mode change 100755 => 100644 resources/fine-uploader/placeholders/waiting-generic.png mode change 100755 => 100644 resources/fontawesome/fontawesome.css mode change 100755 => 100644 resources/icons/android-chrome-512x512.png mode change 100755 => 100644 resources/icons/logo.png create mode 100644 templates/comments/content-list.html diff --git a/dmoj/urls.py b/dmoj/urls.py index 4900d7c..54a7f12 100644 --- a/dmoj/urls.py +++ b/dmoj/urls.py @@ -468,6 +468,8 @@ urlpatterns = [ url(r"^comments/upvote/$", comment.upvote_comment, name="comment_upvote"), url(r"^comments/downvote/$", comment.downvote_comment, name="comment_downvote"), url(r"^comments/hide/$", comment.comment_hide, name="comment_hide"), + url(r"^comments/get_replies/$", comment.get_replies, name="comment_get_replies"), + url(r"^comments/show_more/$", comment.get_show_more, name="comment_show_more"), url( r"^comments/(?P\d+)/", include( diff --git a/judge/comments.py b/judge/comments.py index 08d1cb7..2a2f515 100644 --- a/judge/comments.py +++ b/judge/comments.py @@ -11,6 +11,7 @@ from django.http import ( HttpResponseForbidden, HttpResponseNotFound, HttpResponseRedirect, + Http404, ) from django.urls import reverse_lazy from django.utils.decorators import method_decorator @@ -151,40 +152,92 @@ class CommentedDetailView(TemplateResponseMixin, SingleObjectMixin, View): return self.render_to_response(context) def get(self, request, *args, **kwargs): + pre_query = None + if "comment-id" in request.GET: + comment_id = int(request.GET["comment-id"]) + try: + comment_obj = Comment.objects.get(pk=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 self.object = self.get_object() return self.render_to_response( self.get_context_data( object=self.object, + pre_query=pre_query, comment_form=CommentForm(request, initial={"parent": None}), ) ) - def get_context_data(self, **kwargs): + def get_context_data(self, pre_query=None, **kwargs): context = super(CommentedDetailView, self).get_context_data(**kwargs) queryset = self.object.comments - context["has_comments"] = queryset.exists() - context["comment_lock"] = self.is_comment_locked() - queryset = ( - queryset.select_related("author__user") - .filter(hidden=False) - .defer("author__about") - .annotate(revisions=Count("versions")) - ) - + 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") + .filter(hidden=False) + .defer("author__about") + .annotate(revisions=Count("versions", distinct=True)) + ) + context["comment_remove"] = comment_remove + else: + queryset = ( + queryset.select_related("author__user") + .defer("author__about") + .filter(hidden=False) + .annotate( + count_replies=Count("replies", distinct=True), + revisions=Count("versions", distinct=True), + )[:10] + ) + if self.request.user.is_authenticated: profile = self.request.profile - queryset = queryset.annotate( - my_vote=FilteredRelation( - "votes", condition=Q(votes__voter_id=profile.id) - ), - ).annotate(vote_score=Coalesce(F("my_vote__score"), Value(0))) + 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))) + 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_count"] = len(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 + else: + context["offset"] = 10 + + context["limit"] = 10 + context["comment_count"] = comment_count return context diff --git a/judge/models/comment.py b/judge/models/comment.py index fc9af4c..335d567 100644 --- a/judge/models/comment.py +++ b/judge/models/comment.py @@ -56,6 +56,7 @@ class Comment(MPTTModel): related_name="replies", on_delete=CASCADE, ) + versions = VersionRelation() class Meta: @@ -111,6 +112,15 @@ class Comment(MPTTModel): if len(output) >= n: return output return output + + @cached_property + def get_replies(self): + query = Comment.filter(parent=self) + return len(query) + + @cached_property + def get_revisions(self): + return self.versions.count() @cached_property def page_title(self): @@ -141,7 +151,7 @@ class Comment(MPTTModel): ) def get_absolute_url(self): - return "%s#comment-%d" % (self.link, self.id) + return "%s?comment-id=%d#comment-%d" % (self.link, self.id, self.id) class CommentVote(models.Model): diff --git a/judge/views/comment.py b/judge/views/comment.py index 19085fb..abacb52 100644 --- a/judge/views/comment.py +++ b/judge/views/comment.py @@ -1,8 +1,13 @@ +from django.conf import settings + from django.contrib.auth.decorators import login_required from django.contrib.auth.mixins import LoginRequiredMixin, PermissionRequiredMixin +from django.contrib.auth.context_processors import PermWrapper from django.core.exceptions import PermissionDenied from django.db import IntegrityError, transaction -from django.db.models import F +from django.db.models import Q, F, Count, FilteredRelation +from django.db.models.functions import Coalesce +from django.db.models.expressions import F, Value from django.forms.models import ModelForm from django.http import ( Http404, @@ -15,11 +20,12 @@ from django.utils.translation import gettext as _ from django.views.decorators.http import require_POST from django.views.generic import DetailView, UpdateView from django.urls import reverse_lazy +from django.template import loader from reversion import revisions from reversion.models import Version from judge.dblock import LockModel -from judge.models import Comment, CommentVote, Notification +from judge.models import Comment, CommentVote, Notification, BlogPost from judge.utils.views import TitleMixin from judge.widgets import MathJaxPagedownWidget, HeavyPreviewPageDownWidget from judge.comments import add_mention_notifications, del_mention_notifications @@ -36,6 +42,11 @@ __all__ = [ @login_required + +# def get_more_reply(request, id): +# queryset = Comment.get_pk(id) + + def vote_comment(request, delta): if abs(delta) != 1: return HttpResponseBadRequest( @@ -99,10 +110,77 @@ 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"]) + 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"]) + comment_root_id = 0 + 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: + queryset = queryset.filter(parent=None, hidden=False) + if (comment_remove != -1): + queryset.get(pk=comment_remove).delete() + 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] + ) + if request.user.is_authenticated: + profile = request.profile + queryset = queryset.annotate( + my_vote=FilteredRelation( + "votes", condition=Q(votes__voter_id=profile.id) + ), + ).annotate(vote_score=Coalesce(F("my_vote__score"), Value(0))) + + comment_html = loader.render_to_string( + "comments/content-list.html", + { + "request": request, + "comment_root_id": comment_root_id, + "comment_list": queryset, + "vote_hide_threshold" : settings.DMOJ_COMMENT_VOTE_HIDE_THRESHOLD, + "perms": PermWrapper(request.user), + "offset": offset + min(len(queryset), limit), + "limit": limit, + "comment_count": comment_count, + "comment_parrent_none": parrent_none, + "comment_remove": comment_remove, + } + ) + + 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 diff --git a/locale/vi/LC_MESSAGES/django.po b/locale/vi/LC_MESSAGES/django.po index 4a182fc..268b457 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-04-26 15:39+0700\n" +"POT-Creation-Date: 2023-05-16 16:17+0700\n" "PO-Revision-Date: 2021-07-20 03:44\n" "Last-Translator: Icyene\n" "Language-Team: Vietnamese\n" @@ -25,7 +25,7 @@ msgstr "" msgid "user" msgstr "người dùng" -#: chat_box/models.py:32 judge/models/comment.py:44 judge/models/comment.py:179 +#: chat_box/models.py:32 judge/models/comment.py:44 judge/models/comment.py:189 msgid "posted time" msgstr "thời gian đăng" @@ -41,19 +41,19 @@ msgstr "xem lần cuối" msgid "LQDOJ Chat" msgstr "" -#: dmoj/settings.py:363 +#: dmoj/settings.py:365 msgid "Vietnamese" msgstr "Tiếng Việt" -#: dmoj/settings.py:364 +#: dmoj/settings.py:366 msgid "English" msgstr "" -#: dmoj/urls.py:135 +#: dmoj/urls.py:136 msgid "Login" msgstr "Đăng nhập" -#: dmoj/urls.py:212 templates/base.html:209 +#: dmoj/urls.py:214 templates/base.html:209 #: templates/organization/org-left-sidebar.html:2 msgid "Home" msgstr "Trang chủ" @@ -140,7 +140,7 @@ msgstr[0] "%d kỳ thi đã được đánh dấu ẩn." msgid "Mark contests as hidden" msgstr "Ẩn các kỳ thi" -#: judge/admin/contest.py:377 judge/admin/submission.py:243 +#: judge/admin/contest.py:377 judge/admin/submission.py:248 #, python-format msgid "%d submission was successfully scheduled for rejudging." msgid_plural "%d submissions were successfully scheduled for rejudging." @@ -221,7 +221,7 @@ msgstr "Điểm" msgid "Limits" msgstr "Giới hạn" -#: judge/admin/problem.py:217 judge/admin/submission.py:353 +#: judge/admin/problem.py:217 judge/admin/submission.py:358 #: templates/base.html:245 templates/stats/tab.html:4 #: templates/submission/list.html:347 msgid "Language" @@ -255,12 +255,12 @@ msgstr[0] "%d bài tập đã được đánh dấu riêng tư." msgid "Mark problems as private" msgstr "Đánh dấu các bài tập là riêng tư" -#: judge/admin/problem.py:432 judge/admin/submission.py:316 +#: judge/admin/problem.py:432 judge/admin/submission.py:321 #: templates/problem/list.html:18 templates/problem/list.html:37 msgid "Problem code" msgstr "Mã bài" -#: judge/admin/problem.py:444 judge/admin/submission.py:322 +#: judge/admin/problem.py:444 judge/admin/submission.py:327 msgid "Problem name" msgstr "Tên bài" @@ -284,7 +284,7 @@ msgstr "" msgid "timezone" msgstr "múi giờ" -#: judge/admin/profile.py:125 judge/admin/submission.py:329 +#: judge/admin/profile.py:125 judge/admin/submission.py:334 #: templates/notification/list.html:12 #: templates/organization/requests/log.html:9 #: templates/organization/requests/pending.html:19 @@ -338,7 +338,7 @@ msgid "Capabilities" msgstr "Khả năng" #: judge/admin/submission.py:31 judge/admin/submission.py:53 -#: judge/admin/submission.py:340 +#: judge/admin/submission.py:345 msgid "None" msgstr "None" @@ -360,29 +360,29 @@ msgctxt "contest problem" msgid "%(problem)s in %(contest)s" msgstr "%(problem)s trong %(contest)s" -#: judge/admin/submission.py:215 judge/admin/submission.py:256 +#: judge/admin/submission.py:220 judge/admin/submission.py:261 msgid "You do not have the permission to rejudge submissions." msgstr "Bạn không có quyền chấm lại bài." -#: judge/admin/submission.py:227 +#: judge/admin/submission.py:232 msgid "You do not have the permission to rejudge THAT many submissions." msgstr "Bạn không có quyền chấm lại nhiều bài nộp như vậy." -#: judge/admin/submission.py:250 +#: judge/admin/submission.py:255 msgid "Rejudge the selected submissions" msgstr "Chấm lại các bài nộp đã chọn" -#: judge/admin/submission.py:304 judge/views/problem_manage.py:226 +#: judge/admin/submission.py:309 judge/views/problem_manage.py:226 #, python-format msgid "%d submission were successfully rescored." msgid_plural "%d submissions were successfully rescored." msgstr[0] "%d bài nộp đã được tính điểm lại." -#: judge/admin/submission.py:311 +#: judge/admin/submission.py:316 msgid "Rescore the selected submissions" msgstr "Tính điểm lại cái bài nộp" -#: judge/admin/submission.py:334 templates/notification/list.html:15 +#: judge/admin/submission.py:339 templates/notification/list.html:15 #: templates/organization/requests/log.html:10 #: templates/organization/requests/pending.html:20 #: templates/problem/list.html:154 @@ -391,17 +391,17 @@ msgstr "Tính điểm lại cái bài nộp" msgid "Time" msgstr "Thời gian" -#: judge/admin/submission.py:342 +#: judge/admin/submission.py:347 #, python-format msgid "%d KB" msgstr "%d KB" -#: judge/admin/submission.py:344 +#: judge/admin/submission.py:349 #, python-format msgid "%.2f MB" msgstr "" -#: judge/admin/submission.py:347 templates/submission/status-testcases.html:151 +#: judge/admin/submission.py:352 templates/submission/status-testcases.html:151 msgid "Memory" msgstr "Bộ nhớ" @@ -426,20 +426,20 @@ msgstr "Dạng" msgid "Online Judge" msgstr "" -#: judge/comments.py:60 +#: judge/comments.py:61 msgid "Comment body" msgstr "Nội dung bình luận" -#: judge/comments.py:66 judge/views/ticket.py:78 +#: judge/comments.py:67 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:75 templates/comments/list.html:17 +#: judge/comments.py:76 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:124 +#: judge/comments.py:125 msgid "Posted comment" msgstr "Bình luận đã đăng" @@ -467,7 +467,7 @@ msgstr "" msgid "New IOI" msgstr "IOI mới" -#: judge/forms.py:107 judge/views/organization.py:514 +#: judge/forms.py:107 judge/views/organization.py:520 #: judge/views/register.py:62 #, python-brace-format msgid "You may not be part of more than {count} public groups." @@ -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/list.html:76 +#: templates/comments/content-list.html:35 templates/comments/list.html:77 #, python-brace-format msgid "{time}" msgstr "{time}" @@ -543,19 +543,19 @@ msgstr "{time}" msgid "on {time}" msgstr "vào {time}" -#: judge/middleware.py:131 +#: judge/middleware.py:135 msgid "No permission" msgstr "Không có quyền truy cập" -#: judge/middleware.py:132 +#: judge/middleware.py:136 msgid "You need to join this group first" msgstr "Bạn phải là thành viên của nhóm." -#: judge/middleware.py:142 judge/middleware.py:143 +#: judge/middleware.py:146 judge/middleware.py:147 msgid "No such group" msgstr "Nhóm không tồn tại" -#: judge/models/bookmark.py:14 judge/models/comment.py:161 +#: judge/models/bookmark.py:14 judge/models/comment.py:171 #: judge/models/pagevote.py:13 msgid "associated page" msgstr "trang tương ứng" @@ -621,56 +621,49 @@ msgstr "ẩn bình luận" msgid "parent" msgstr "" -#: judge/models/comment.py:62 judge/models/comment.py:181 +#: judge/models/comment.py:63 judge/models/comment.py:191 msgid "comment" msgstr "bình luận" -#: judge/models/comment.py:63 +#: judge/models/comment.py:64 msgid "comments" msgstr "" -#: judge/models/comment.py:122 +#: judge/models/comment.py:132 #, fuzzy #| msgid "Editorial for {0}" msgid "Editorial for " msgstr "Hướng dẫn cho {0}" -#: judge/models/comment.py:154 +#: judge/models/comment.py:164 msgid "comment vote" msgstr "" -#: judge/models/comment.py:155 +#: judge/models/comment.py:165 msgid "comment votes" msgstr "" -#: judge/models/comment.py:166 +#: judge/models/comment.py:176 msgid "Override comment lock" msgstr "" -#: judge/models/comment.py:175 -#: src/dmoj-wpadmin/test_project/apps/books/admin.py:24 -#: src/dmoj-wpadmin/test_project/apps/books/models.py:30 -#: src/dmoj-wpadmin/test_project/apps/cds/models.py:30 -#: src/dmoj-wpadmin/test_project/apps/dvds/models.py:30 +#: judge/models/comment.py:185 msgid "owner" msgstr "" -#: judge/models/comment.py:183 judge/models/message.py:28 +#: judge/models/comment.py:193 judge/models/message.py:28 msgid "read" msgstr "" -#: judge/models/comment.py:184 -#: src/dmoj-wpadmin/test_project/apps/books/models.py:28 -#: src/dmoj-wpadmin/test_project/apps/cds/models.py:28 -#: src/dmoj-wpadmin/test_project/apps/dvds/models.py:28 +#: judge/models/comment.py:194 msgid "category" msgstr "" -#: judge/models/comment.py:187 +#: judge/models/comment.py:197 msgid "html link to comments, used for non-comments" msgstr "" -#: judge/models/comment.py:193 +#: judge/models/comment.py:203 msgid "who trigger, used for non-comment" msgstr "" @@ -739,13 +732,6 @@ msgstr "" #: judge/models/contest.py:118 judge/models/course.py:158 #: judge/models/runtime.py:211 -#: src/dmoj-wpadmin/test_project/apps/books/admin.py:20 -#: src/dmoj-wpadmin/test_project/apps/books/models.py:13 -#: src/dmoj-wpadmin/test_project/apps/books/models.py:27 -#: src/dmoj-wpadmin/test_project/apps/cds/models.py:13 -#: src/dmoj-wpadmin/test_project/apps/cds/models.py:27 -#: src/dmoj-wpadmin/test_project/apps/dvds/models.py:13 -#: src/dmoj-wpadmin/test_project/apps/dvds/models.py:27 msgid "description" msgstr "mô tả" @@ -2660,24 +2646,24 @@ msgstr "Báo cáo" msgid "Comment feed" msgstr "Bình luận" -#: judge/views/comment.py:42 judge/views/pagevote.py:31 +#: judge/views/comment.py:53 judge/views/pagevote.py:31 msgid "Messing around, are we?" msgstr "Messing around, are we?" -#: judge/views/comment.py:58 judge/views/pagevote.py:47 +#: judge/views/comment.py:69 judge/views/pagevote.py:47 msgid "You must solve at least one problem before you can vote." msgstr "Bạn phải giải ít nhất 1 bài trước khi được vote." -#: judge/views/comment.py:89 +#: judge/views/comment.py:100 msgid "You already voted." msgstr "Bạn đã vote." -#: judge/views/comment.py:165 judge/views/organization.py:811 -#: judge/views/organization.py:957 judge/views/organization.py:1122 +#: judge/views/comment.py:243 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:186 +#: judge/views/comment.py:264 msgid "Editing comment" msgstr "Chỉnh sửa bình luận" @@ -2879,13 +2865,13 @@ msgstr "Không thể chỉnh sửa tổ chức" msgid "You are not allowed to edit this organization." msgstr "Bạn không được phép chỉnh sửa tổ chức này." -#: judge/views/organization.py:193 judge/views/organization.py:337 +#: judge/views/organization.py:193 judge/views/organization.py:340 #, fuzzy #| msgid "Can't edit organization" msgid "Can't access organization" msgstr "Không thể chỉnh sửa tổ chức" -#: judge/views/organization.py:194 judge/views/organization.py:338 +#: judge/views/organization.py:194 judge/views/organization.py:341 msgid "You are not allowed to access this organization." msgstr "Bạn không được phép chỉnh sửa tổ chức này." @@ -2896,57 +2882,57 @@ msgstr "Bạn không được phép chỉnh sửa tổ chức này." msgid "Groups" msgstr "Nhóm" -#: judge/views/organization.py:344 +#: judge/views/organization.py:347 #, python-format msgid "%s Members" msgstr "%s Thành viên" -#: judge/views/organization.py:470 +#: judge/views/organization.py:476 #, python-brace-format msgid "All submissions in {0}" msgstr "Bài nộp trong {0}" -#: judge/views/organization.py:500 judge/views/organization.py:506 -#: judge/views/organization.py:513 +#: judge/views/organization.py:506 judge/views/organization.py:512 +#: judge/views/organization.py:519 msgid "Joining group" msgstr "Tham gia nhóm" -#: judge/views/organization.py:501 +#: judge/views/organization.py:507 msgid "You are already in the group." msgstr "Bạn đã ở trong nhóm." -#: judge/views/organization.py:506 +#: judge/views/organization.py:512 msgid "This group is not open." msgstr "Nhóm này là nhóm kín." -#: judge/views/organization.py:529 +#: judge/views/organization.py:535 msgid "Leaving group" msgstr "Rời nhóm" -#: judge/views/organization.py:530 +#: judge/views/organization.py:536 #, python-format msgid "You are not in \"%s\"." msgstr "Bạn không ở trong \"%s\"." -#: judge/views/organization.py:555 +#: judge/views/organization.py:561 #, python-format msgid "Request to join %s" msgstr "Đăng ký tham gia %s" -#: judge/views/organization.py:585 +#: judge/views/organization.py:591 msgid "Join request detail" msgstr "Chi tiết đơn đăng ký" -#: judge/views/organization.py:627 +#: judge/views/organization.py:633 msgid "Manage join requests" msgstr "Quản lý đơn đăng ký" -#: judge/views/organization.py:631 +#: judge/views/organization.py:637 #, python-format msgid "Managing join requests for %s" msgstr "Quản lý đơn đăng ký cho %s" -#: judge/views/organization.py:671 +#: judge/views/organization.py:677 #, python-format msgid "" "Your organization can only receive %d more members. You cannot approve %d " @@ -2955,96 +2941,96 @@ msgstr "" "Tổ chức chỉ có thể chứa %d thành viên. Bạn không thể chấp thuận nhiều hơn %d " "người." -#: judge/views/organization.py:689 +#: judge/views/organization.py:695 #, python-format msgid "Approved %d user." msgid_plural "Approved %d users." msgstr[0] "Đã chấp thuận %d người." -#: judge/views/organization.py:692 +#: judge/views/organization.py:698 #, python-format msgid "Rejected %d user." msgid_plural "Rejected %d users." msgstr[0] "Đã từ chối %d người." -#: judge/views/organization.py:732 +#: judge/views/organization.py:738 #, python-format msgid "Add member for %s" msgstr "Thêm thành viên cho %s" -#: judge/views/organization.py:744 +#: judge/views/organization.py:750 #, fuzzy #| msgid "Edited from site" msgid "Added members from site" msgstr "Chỉnh sửa từ web" -#: judge/views/organization.py:764 judge/views/organization.py:772 +#: judge/views/organization.py:770 judge/views/organization.py:778 msgid "Can't kick user" msgstr "Không thể đuổi" -#: judge/views/organization.py:765 +#: judge/views/organization.py:771 msgid "The user you are trying to kick does not exist!" msgstr "" -#: judge/views/organization.py:773 +#: judge/views/organization.py:779 #, python-format msgid "The user you are trying to kick is not in organization: %s." msgstr "" -#: judge/views/organization.py:794 judge/views/organization.py:946 +#: judge/views/organization.py:800 judge/views/organization.py:952 #, fuzzy, python-format #| msgid "Editing %s" msgid "Edit %s" msgstr "Đang chỉnh sửa %s" -#: judge/views/organization.py:822 templates/organization/list.html:45 +#: judge/views/organization.py:828 templates/organization/list.html:45 msgid "Create group" msgstr "Tạo nhóm" -#: judge/views/organization.py:837 +#: judge/views/organization.py:843 msgid "Exceeded limit" msgstr "" -#: judge/views/organization.py:838 +#: judge/views/organization.py:844 #, python-format msgid "You created too many groups. You can only create at most %d groups" msgstr "" -#: judge/views/organization.py:843 judge/views/organization.py:868 -#: judge/views/organization.py:1012 +#: judge/views/organization.py:849 judge/views/organization.py:874 +#: judge/views/organization.py:1018 msgid "Added from site" msgstr "Thêm từ web" -#: judge/views/organization.py:859 +#: judge/views/organization.py:865 #: templates/organization/org-right-sidebar.html:55 msgid "Add contest" msgstr "Thêm kỳ thi" -#: judge/views/organization.py:902 judge/views/organization.py:1064 +#: judge/views/organization.py:908 judge/views/organization.py:1070 msgid "Permission denied" msgstr "Truy cập bị từ chối" -#: judge/views/organization.py:903 +#: judge/views/organization.py:909 #, fuzzy #| msgid "You are not allowed to edit this organization." msgid "You are not allowed to edit this contest" msgstr "Bạn không được phép chỉnh sửa tổ chức này." -#: judge/views/organization.py:1001 +#: judge/views/organization.py:1007 #, python-format msgid "Add blog for %s" msgstr "Thêm bài đăng cho %s" -#: judge/views/organization.py:1065 +#: judge/views/organization.py:1071 msgid "Not allowed to edit this blog" msgstr "Bạn không được phép chỉnh sửa bài đăng này." -#: judge/views/organization.py:1097 +#: judge/views/organization.py:1103 #, python-format msgid "Edit blog %s" msgstr "Chỉnh sửa %s" -#: judge/views/organization.py:1148 +#: judge/views/organization.py:1154 #, python-format msgid "Pending blogs in %s" msgstr "Bài đang đợi duyệt trong %s" @@ -3097,12 +3083,12 @@ msgstr "Quá nhiều lần nộp" msgid "You have exceeded the submission limit for this problem." msgstr "Bạn đã vượt quá số lần nộp cho bài này." -#: judge/views/problem.py:1177 judge/views/problem.py:1182 +#: judge/views/problem.py:1176 judge/views/problem.py:1181 #, python-format msgid "Submit to %(problem)s" msgstr "Nộp bài cho %(problem)s" -#: judge/views/problem.py:1208 +#: judge/views/problem.py:1207 msgid "Clone Problem" msgstr "Nhân bản bài tập" @@ -3302,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}" @@ -3431,147 +3417,6 @@ msgstr "Dữ liệu không hợp lệ: %s" msgid "Bad latitude or longitude" msgstr "Kinh độ / Vĩ độ không hợp lệ" -#: src/dmoj-wpadmin/test_project/apps/authors/models.py:9 -#, fuzzy -#| msgid "short name" -msgid "first name" -msgstr "tên ngắn" - -#: src/dmoj-wpadmin/test_project/apps/authors/models.py:10 -#, fuzzy -#| msgid "short name" -msgid "last name" -msgstr "tên ngắn" - -#: src/dmoj-wpadmin/test_project/apps/authors/models.py:11 -msgid "biography" -msgstr "tiểu sử" - -#: src/dmoj-wpadmin/test_project/apps/books/models.py:12 -#: src/dmoj-wpadmin/test_project/apps/cds/models.py:12 -#: src/dmoj-wpadmin/test_project/apps/dvds/models.py:12 -msgid "name" -msgstr "tên" - -#: src/dmoj-wpadmin/test_project/apps/books/models.py:19 -msgid "Category of Books" -msgstr "Thể loại sách" - -#: src/dmoj-wpadmin/test_project/apps/books/models.py:20 -msgid "Categories of Books" -msgstr "Thể loại sách" - -#: src/dmoj-wpadmin/test_project/apps/books/models.py:26 -#: src/dmoj-wpadmin/test_project/apps/cds/models.py:26 -#: src/dmoj-wpadmin/test_project/apps/dvds/models.py:26 -msgid "title" -msgstr "tiêu đề" - -#: src/dmoj-wpadmin/test_project/apps/books/models.py:29 -#: src/dmoj-wpadmin/test_project/apps/cds/models.py:29 -#: src/dmoj-wpadmin/test_project/apps/dvds/models.py:29 -msgid "author" -msgstr "tác giả" - -#: src/dmoj-wpadmin/test_project/apps/books/models.py:31 -msgid "publication date" -msgstr "ngày xuất bản" - -#: src/dmoj-wpadmin/test_project/apps/books/models.py:37 -msgid "Book" -msgstr "Sách" - -#: src/dmoj-wpadmin/test_project/apps/books/models.py:38 -#: src/dmoj-wpadmin/test_project/test_project/wp.py:136 -msgid "Books" -msgstr "Sách" - -#: src/dmoj-wpadmin/test_project/apps/cds/models.py:19 -msgid "Category of CDs" -msgstr "Thể loại CDs" - -#: src/dmoj-wpadmin/test_project/apps/cds/models.py:20 -msgid "Categories of CDs" -msgstr "Thể loại CDs" - -#: src/dmoj-wpadmin/test_project/apps/cds/models.py:36 -msgid "CD" -msgstr "" - -#: src/dmoj-wpadmin/test_project/apps/cds/models.py:37 -#: src/dmoj-wpadmin/test_project/test_project/wp.py:141 -msgid "CDs" -msgstr "" - -#: src/dmoj-wpadmin/test_project/apps/dvds/models.py:19 -msgid "Category of DVDs" -msgstr "Thể loại DVDs" - -#: src/dmoj-wpadmin/test_project/apps/dvds/models.py:20 -msgid "Categories of DVDs" -msgstr "Thể loại DVDs" - -#: src/dmoj-wpadmin/test_project/apps/dvds/models.py:36 -msgid "DVD" -msgstr "" - -#: src/dmoj-wpadmin/test_project/apps/dvds/models.py:37 -#: src/dmoj-wpadmin/test_project/test_project/wp.py:146 -msgid "DVDs" -msgstr "" - -#: src/dmoj-wpadmin/test_project/templates/admin/base_site.html:7 -msgid "Django administration" -msgstr "Quản trị viên Django" - -#: src/dmoj-wpadmin/test_project/test_project/forms.py:12 -#, python-format -msgid "" -"Please enter the correct %(username)s and password for an admin account. " -"Note that both fields may be case-sensitive." -msgstr "" -"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." - -#: src/dmoj-wpadmin/test_project/test_project/forms.py:32 -#, python-format -msgid "" -"Please enter the correct %(username)s and password for an user account. Note " -"that both fields may be case-sensitive." -msgstr "" -"Hãy nhập %(username)s và mật khẩu hợp lệ cho tài khoản thành viên. Chú ý cả " -"hai trường có phân biệt chữ Hoa-thường." - -#: src/dmoj-wpadmin/test_project/test_project/wp.py:27 -#: templates/stats/tab.html:5 -msgid "Site" -msgstr "Trang" - -#: src/dmoj-wpadmin/test_project/test_project/wp.py:38 -#: src/dmoj-wpadmin/test_project/test_project/wp.py:41 -#: src/dmoj-wpadmin/test_project/test_project/wp.py:130 -#: src/dmoj-wpadmin/test_project/test_project/wp.py:133 -msgid "Dashboard" -msgstr "Bảng điều khiển" - -#: src/dmoj-wpadmin/test_project/test_project/wp.py:48 -msgid "Applications" -msgstr "Ứng dụng" - -#: src/dmoj-wpadmin/test_project/test_project/wp.py:53 -#, fuzzy -#| msgid "administrators" -msgid "Administration" -msgstr "người quản lý" - -#: src/dmoj-wpadmin/test_project/test_project/wp.py:64 -msgid "Color theme" -msgstr "Chủ đề màu sắc" - -#: src/dmoj-wpadmin/test_project/test_project/wp.py:66 -msgid "Change color theme" -msgstr "Đổi chủ đề màu sắc" - #: templates/actionbar/list.html:15 msgid "Like" msgstr "Thích" @@ -3657,7 +3502,8 @@ msgid "Profile" msgstr "Trang cá nhân" #: templates/base.html:276 templates/chat/chat.html:21 -#: templates/comments/list.html:125 templates/contest/contest-list-tabs.html:4 +#: templates/comments/content-list.html:80 templates/comments/list.html:126 +#: 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 #: templates/problem/left-sidebar.html:6 @@ -3713,8 +3559,9 @@ msgstr "" msgid " posted on %(time)s" msgstr "đã đăng vào %(time)s" -#: templates/blog/blog.html:31 templates/comments/list.html:104 -#: templates/comments/list.html:119 templates/contest/contest-tabs.html:35 +#: 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 @@ -3852,6 +3699,68 @@ 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 +msgid "Please login to vote" +msgstr "Đăng nhập để vote" + +#: templates/comments/content-list.html:43 templates/comments/list.html:86 +#, 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 +msgid "edited" +msgstr "đã chỉnh sửa" + +#: templates/comments/content-list.html:54 templates/comments/list.html:97 +#: 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 +msgid "Reply" +msgstr "Phản hồi" + +#: templates/comments/content-list.html:78 templates/comments/list.html:123 +msgid "Hide" +msgstr "Ẩn" + +#: templates/comments/content-list.html:92 +#, fuzzy, python-format +#| msgid "" +#| "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." +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 +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" +msgstr "bình luận nữa" + #: templates/comments/list.html:6 msgid "Write comment" msgstr "Thêm bình luận" @@ -3868,45 +3777,20 @@ msgstr "Nội dung không hợp lệ." msgid "Post!" msgstr "Đăng!" -#: templates/comments/list.html:54 templates/comments/list.html:63 -msgid "Please login to vote" -msgstr "Đăng nhập để vote" - -#: templates/comments/list.html:85 -#, python-format -msgid "edit %(edits)s" -msgstr "chỉnh sửa %(edits)s" - -#: templates/comments/list.html:87 templates/comments/media-js.html:96 -msgid "edited" -msgstr "đã chỉnh sửa" - -#: templates/comments/list.html:96 templates/notification/list.html:14 -msgid "Link" -msgstr "Link" - -#: templates/comments/list.html:109 templates/comments/list.html:116 -msgid "Reply" -msgstr "Trả lời" - -#: templates/comments/list.html:122 -msgid "Hide" -msgstr "Ẩn" - -#: templates/comments/list.html:137 +#: templates/comments/list.html:138 #, 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." 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:154 +#: templates/comments/list.html:177 msgid "There are no comments at the moment." msgstr "Không có bình luận nào." -#: templates/comments/list.html:159 +#: templates/comments/list.html:182 msgid "Comments are disabled on this page." msgstr "Bình luận bị tắt trong trang này." @@ -4034,8 +3918,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" @@ -5257,6 +5141,10 @@ msgstr "Thống kê" msgid "AC Submissions by Language" msgstr "Thống kê AC theo ngôn ngữ" +#: templates/stats/tab.html:5 +msgid "Site" +msgstr "Trang" + #: templates/status/judge-status-table.html:4 msgid "Online" msgstr "Trực tuyến" @@ -5864,6 +5752,91 @@ msgstr "Thông tin" msgid "Check all" msgstr "Chọn tất cả" +#, fuzzy +#~| msgid "short name" +#~ msgid "first name" +#~ msgstr "tên ngắn" + +#, fuzzy +#~| msgid "short name" +#~ msgid "last name" +#~ msgstr "tên ngắn" + +#~ msgid "biography" +#~ msgstr "tiểu sử" + +#~ msgid "name" +#~ msgstr "tên" + +#~ msgid "Category of Books" +#~ msgstr "Thể loại sách" + +#~ msgid "Categories of Books" +#~ msgstr "Thể loại sách" + +#~ msgid "title" +#~ msgstr "tiêu đề" + +#~ msgid "author" +#~ msgstr "tác giả" + +#~ msgid "publication date" +#~ msgstr "ngày xuất bản" + +#~ msgid "Book" +#~ msgstr "Sách" + +#~ msgid "Books" +#~ msgstr "Sách" + +#~ msgid "Category of CDs" +#~ msgstr "Thể loại CDs" + +#~ msgid "Categories of CDs" +#~ msgstr "Thể loại CDs" + +#~ msgid "Category of DVDs" +#~ msgstr "Thể loại DVDs" + +#~ msgid "Categories of DVDs" +#~ msgstr "Thể loại DVDs" + +#~ 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." +#~ msgstr "" +#~ "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." +#~ msgstr "" +#~ "Hãy nhập %(username)s và mật khẩu hợp lệ cho tài khoản thành viên. Chú ý " +#~ "cả hai trường có phân biệt chữ Hoa-thường." + +#~ msgid "Dashboard" +#~ msgstr "Bảng điều khiển" + +#~ msgid "Applications" +#~ msgstr "Ứng dụng" + +#, fuzzy +#~| msgid "administrators" +#~ msgid "Administration" +#~ msgstr "người quản lý" + +#~ msgid "Color theme" +#~ msgstr "Chủ đề màu sắc" + +#~ msgid "Change color theme" +#~ msgstr "Đổi chủ đề màu sắc" + #~ msgid "commented on {time}" #~ msgstr "bình luận vào {time}" diff --git a/locale/vi/LC_MESSAGES/dmoj-user.po b/locale/vi/LC_MESSAGES/dmoj-user.po index ffd36e9..c65744d 100644 --- a/locale/vi/LC_MESSAGES/dmoj-user.po +++ b/locale/vi/LC_MESSAGES/dmoj-user.po @@ -33,9 +33,6 @@ 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" @@ -345,6 +342,9 @@ msgstr "" msgid "ltt" msgstr "" +msgid "Luyện tập" +msgstr "" + msgid "manacher" msgstr "" @@ -593,3 +593,6 @@ msgstr "" msgid "z-function" msgstr "" + +#~ msgid "Name" +#~ msgstr "Đăng ký tên" diff --git a/make_style.sh b/make_style.sh old mode 100755 new mode 100644 diff --git a/manage.py b/manage.py old mode 100755 new mode 100644 diff --git a/resources/bootstrap/bootstrap.min.css b/resources/bootstrap/bootstrap.min.css old mode 100755 new mode 100644 diff --git a/resources/comments.scss b/resources/comments.scss index 9abca9e..da828b4 100644 --- a/resources/comments.scss +++ b/resources/comments.scss @@ -126,6 +126,28 @@ a { margin: -50px 23px 10px -40px; padding-top: 50px; } + + .show_more_reply { + font-weight: bold; + display: flex; + margin: 16px 40px; + align-items: center; + + svg { + margin-right: 4px; + } + } + + .show_more_comment { + font-weight: bold; + display: flex; + margin: 16px -40px; + align-items: center; + + svg { + margin-right: 4px; + } + } } .no-comments-message { diff --git a/resources/fine-uploader/placeholders/not_available-generic.png b/resources/fine-uploader/placeholders/not_available-generic.png old mode 100755 new mode 100644 diff --git a/resources/fine-uploader/placeholders/waiting-generic.png b/resources/fine-uploader/placeholders/waiting-generic.png old mode 100755 new mode 100644 diff --git a/resources/fontawesome/fontawesome.css b/resources/fontawesome/fontawesome.css old mode 100755 new mode 100644 diff --git a/resources/icons/android-chrome-512x512.png b/resources/icons/android-chrome-512x512.png old mode 100755 new mode 100644 diff --git a/resources/icons/logo.png b/resources/icons/logo.png old mode 100755 new mode 100644 diff --git a/templates/actionbar/list.html b/templates/actionbar/list.html index 0bad8e1..bbed0bc 100644 --- a/templates/actionbar/list.html +++ b/templates/actionbar/list.html @@ -29,7 +29,7 @@ {% if comment_count %} - ({{comment_count}}) + ({{ comment_count }}) {% endif %} diff --git a/templates/comments/content-list.html b/templates/comments/content-list.html new file mode 100644 index 0000000..0c3408d --- /dev/null +++ b/templates/comments/content-list.html @@ -0,0 +1,139 @@ +{% 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 %} + + {% 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 %} +
    +
    +
    + + {% if node.count_replies > 1 %} + + + + + + {{ node.count_replies }} {{ _('replies') }} + {% elif node.count_replies %} + + + + + + {{ node.count_replies }} {{ _('reply') }} + {% endif %} +
  • + +
    +{% 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 %} + diff --git a/templates/comments/list.html b/templates/comments/list.html index 6adf903..9977eb5 100644 --- a/templates/comments/list.html +++ b/templates/comments/list.html @@ -36,14 +36,15 @@ {% endif %} {% endif %} - {% if has_comments %} -
      + {% if has_comments or comment_all_list %} +
        {% 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 comment_all_list %} + {% for node in mptt_tree(comment_all_list) recursive %}
      • + data-max-revision="{{ node.revisions - 1 }}" + data-revision-ajax="{{ url('comment_revision_ajax', node.id) }}" class="comment">
        @@ -149,6 +150,28 @@ {% 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 b1131d5..131d040 100644 --- a/templates/comments/media-js.html +++ b/templates/comments/media-js.html @@ -119,6 +119,77 @@ } }); } + const queryString = window.location.search; + const urlParams = new URLSearchParams(queryString); + const comment_remove = urlParams.get('comment-id'); + console.log(comment_remove); + + window.comment_get_replies = function (id, parrent_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); + } + + function ajax_get_reply(url, id, parrent_none) { + return $.ajax({ + url: url, + type: 'GET', + data: { + id: id, + parrent_none: parrent_none, + }, + success: function(data) { + var $comment_loading = $("#comment-" + id + "-children .loading"); + $comment_loading.hide(); + var $comment = $("#comment-" + id + "-children"); + $comment.append(data); + } + }) + } + + window.comment_show_more = function (id, parrent_none, offset, comment_remove) { + console.log(parrent_none) + if (parrent_none == 1) { + var $comment_show_btn = $("#comment-0" + " .show_more_comment"); + $comment_show_btn.hide(); + var $comment = $("#comment-0"); + $comment.append("

      Loading...

      "); + } else { + var $comment_show_btn = $("#comment-" + id + "-children" + " .show_more_comment"); + $comment_show_btn.hide(); + var $comment = $("#comment-" + id + "-children"); + $comment.append("

      Loading...

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