Compare commits

...

3 commits

Author SHA1 Message Date
Phuoc Dinh Le
da2a11adf9 Revert "Revert "Change comment style (#67)" (#68)"
This reverts commit 0494a36681.
2023-05-20 08:54:17 +09:00
Phuoc Dinh Le
0494a36681
Revert "Change comment style (#67)" (#68)
This reverts commit 411f3da45e.
2023-05-20 08:53:43 +09:00
Dung T.Bui
411f3da45e
Change comment style (#67) 2023-05-20 08:52:37 +09:00
784 changed files with 696 additions and 307 deletions

0
.browserslistrc Normal file → Executable file
View file

0
.flake8 Normal file → Executable file
View file

0
.github/workflows/init.yml vendored Normal file → Executable file
View file

0
.gitignore vendored Normal file → Executable file
View file

0
.pre-commit-config.yaml Normal file → Executable file
View file

0
502.html Normal file → Executable file
View file

0
LICENSE Normal file → Executable file
View file

0
README.md Normal file → Executable file
View file

0
chat_box/__init__.py Normal file → Executable file
View file

0
chat_box/apps.py Normal file → Executable file
View file

0
chat_box/migrations/0001_initial.py Normal file → Executable file
View file

0
chat_box/migrations/0002_message_hidden.py Normal file → Executable file
View file

0
chat_box/migrations/0003_auto_20200505_2306.py Normal file → Executable file
View file

0
chat_box/migrations/0004_auto_20200505_2336.py Normal file → Executable file
View file

0
chat_box/migrations/0005_auto_20211011_0714.py Normal file → Executable file
View file

0
chat_box/migrations/0006_userroom.py Normal file → Executable file
View file

0
chat_box/migrations/0007_auto_20211112_1255.py Normal file → Executable file
View file

0
chat_box/migrations/0008_ignore.py Normal file → Executable file
View file

0
chat_box/migrations/0009_auto_20220618_1452.py Normal file → Executable file
View file

0
chat_box/migrations/0010_auto_20221028_0300.py Normal file → Executable file
View file

0
chat_box/migrations/0011_alter_message_hidden.py Normal file → Executable file
View file

0
chat_box/migrations/0012_auto_20230308_1417.py Normal file → Executable file
View file

0
chat_box/migrations/__init__.py Normal file → Executable file
View file

0
chat_box/models.py Normal file → Executable file
View file

0
chat_box/utils.py Normal file → Executable file
View file

0
chat_box/views.py Normal file → Executable file
View file

0
django_2_2_pymysql_patch.py Normal file → Executable file
View file

0
django_ace/__init__.py Normal file → Executable file
View file

0
django_ace/static/django_ace/img/contract.png Normal file → Executable file
View file

Before

Width:  |  Height:  |  Size: 304 B

After

Width:  |  Height:  |  Size: 304 B

0
django_ace/static/django_ace/img/expand.png Normal file → Executable file
View file

Before

Width:  |  Height:  |  Size: 285 B

After

Width:  |  Height:  |  Size: 285 B

0
django_ace/static/django_ace/widget.css Normal file → Executable file
View file

0
django_ace/static/django_ace/widget.js Normal file → Executable file
View file

0
django_ace/widgets.py Normal file → Executable file
View file

0
dmoj/__init__.py Normal file → Executable file
View file

0
dmoj/celery.py Normal file → Executable file
View file

15
dmoj/settings.py Normal file → Executable file
View file

@ -219,6 +219,7 @@ else:
}
INSTALLED_APPS += (
"debug_toolbar",
"django.contrib.admin",
"judge",
"django.contrib.auth",
@ -248,6 +249,7 @@ INSTALLED_APPS += (
)
MIDDLEWARE = (
"debug_toolbar.middleware.DebugToolbarMiddleware",
"judge.middleware.SlowRequestMiddleware",
"judge.middleware.ShortCircuitMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
@ -421,7 +423,12 @@ STATICFILES_DIRS = [
STATIC_URL = "/static/"
# Define a cache
CACHES = {}
CACHES = {
"default": {
"BACKEND": "django.core.cache.backends.memcached.PyMemcacheCache",
"LOCATION": "127.0.0.1:11211",
}
}
# Authentication
AUTHENTICATION_BACKENDS = (
@ -481,3 +488,9 @@ except IOError:
pass
DEFAULT_AUTO_FIELD = "django.db.models.AutoField"
INTERNAL_IPS = [
# ...
"127.0.0.1",
# ...
]

0
dmoj/throttle_mail.py Normal file → Executable file
View file

4
dmoj/urls.py Normal file → Executable file
View file

@ -1,5 +1,6 @@
import chat_box.views as chat
from django.urls import include, path
from django.conf import settings
from django.conf.urls import include, url
from django.contrib import admin
@ -206,6 +207,7 @@ def paged_list_view(view, name, **kwargs):
urlpatterns = [
path('__debug__/', include('debug_toolbar.urls')),
url("", include("pagedown.urls")),
url(
r"^$",
@ -468,6 +470,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<id>\d+)/",
include(

0
dmoj/wsgi.py Normal file → Executable file
View file

0
dmoj/wsgi_async.py Normal file → Executable file
View file

0
dmoj_bridge_async.py Normal file → Executable file
View file

0
dmoj_celery.py Normal file → Executable file
View file

0
dmoj_install_pymysql.py Normal file → Executable file
View file

0
judge/__init__.py Normal file → Executable file
View file

0
judge/admin/__init__.py Normal file → Executable file
View file

0
judge/admin/comments.py Normal file → Executable file
View file

0
judge/admin/contest.py Normal file → Executable file
View file

0
judge/admin/interface.py Normal file → Executable file
View file

0
judge/admin/organization.py Normal file → Executable file
View file

0
judge/admin/problem.py Normal file → Executable file
View file

0
judge/admin/profile.py Normal file → Executable file
View file

0
judge/admin/runtime.py Normal file → Executable file
View file

0
judge/admin/submission.py Normal file → Executable file
View file

0
judge/admin/taxon.py Normal file → Executable file
View file

0
judge/admin/ticket.py Normal file → Executable file
View file

0
judge/admin/volunteer.py Normal file → Executable file
View file

0
judge/apps.py Normal file → Executable file
View file

0
judge/bridge/__init__.py Normal file → Executable file
View file

0
judge/bridge/base_handler.py Normal file → Executable file
View file

0
judge/bridge/daemon.py Normal file → Executable file
View file

0
judge/bridge/django_handler.py Normal file → Executable file
View file

0
judge/bridge/echo_test_client.py Normal file → Executable file
View file

0
judge/bridge/echo_test_server.py Normal file → Executable file
View file

0
judge/bridge/judge_handler.py Normal file → Executable file
View file

0
judge/bridge/judge_list.py Normal file → Executable file
View file

0
judge/bridge/server.py Normal file → Executable file
View file

0
judge/caching.py Normal file → Executable file
View file

83
judge/comments.py Normal file → Executable file
View file

@ -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

0
judge/contest_format/__init__.py Normal file → Executable file
View file

0
judge/contest_format/atcoder.py Normal file → Executable file
View file

0
judge/contest_format/base.py Normal file → Executable file
View file

0
judge/contest_format/default.py Normal file → Executable file
View file

0
judge/contest_format/ecoo.py Normal file → Executable file
View file

0
judge/contest_format/icpc.py Normal file → Executable file
View file

0
judge/contest_format/ioi.py Normal file → Executable file
View file

0
judge/contest_format/new_ioi.py Normal file → Executable file
View file

0
judge/contest_format/registry.py Normal file → Executable file
View file

0
judge/dblock.py Normal file → Executable file
View file

0
judge/event_poster.py Normal file → Executable file
View file

0
judge/event_poster_amqp.py Normal file → Executable file
View file

0
judge/event_poster_ws.py Normal file → Executable file
View file

0
judge/feed.py Normal file → Executable file
View file

0
judge/fixtures/demo.json Normal file → Executable file
View file

0
judge/fixtures/language_small.json Normal file → Executable file
View file

0
judge/fixtures/navbar.json Normal file → Executable file
View file

0
judge/forms.py Normal file → Executable file
View file

0
judge/fulltext.py Normal file → Executable file
View file

0
judge/highlight_code.py Normal file → Executable file
View file

0
judge/jinja2/__init__.py Normal file → Executable file
View file

0
judge/jinja2/camo.py Normal file → Executable file
View file

0
judge/jinja2/chat.py Normal file → Executable file
View file

0
judge/jinja2/datetime.py Normal file → Executable file
View file

0
judge/jinja2/filesize.py Normal file → Executable file
View file

0
judge/jinja2/gravatar.py Normal file → Executable file
View file

0
judge/jinja2/language.py Normal file → Executable file
View file

0
judge/jinja2/markdown/__init__.py Normal file → Executable file
View file

0
judge/jinja2/rating.py Normal file → Executable file
View file

0
judge/jinja2/reference.py Normal file → Executable file
View file

0
judge/jinja2/registry.py Normal file → Executable file
View file

0
judge/jinja2/render.py Normal file → Executable file
View file

Some files were not shown because too many files have changed in this diff Show more