This reverts commit 411f3da45e
.
This commit is contained in:
parent
411f3da45e
commit
0494a36681
784 changed files with 307 additions and 696 deletions
0
.browserslistrc
Executable file → Normal file
0
.browserslistrc
Executable file → Normal file
0
.flake8
Executable file → Normal file
0
.flake8
Executable file → Normal file
0
.github/workflows/init.yml
vendored
Executable file → Normal file
0
.github/workflows/init.yml
vendored
Executable file → Normal file
0
.gitignore
vendored
Executable file → Normal file
0
.gitignore
vendored
Executable file → Normal file
0
.pre-commit-config.yaml
Executable file → Normal file
0
.pre-commit-config.yaml
Executable file → Normal file
0
502.html
Executable file → Normal file
0
502.html
Executable file → Normal file
0
LICENSE
Executable file → Normal file
0
LICENSE
Executable file → Normal file
0
README.md
Executable file → Normal file
0
README.md
Executable file → Normal file
0
chat_box/__init__.py
Executable file → Normal file
0
chat_box/__init__.py
Executable file → Normal file
0
chat_box/apps.py
Executable file → Normal file
0
chat_box/apps.py
Executable file → Normal file
0
chat_box/migrations/0001_initial.py
Executable file → Normal file
0
chat_box/migrations/0001_initial.py
Executable file → Normal file
0
chat_box/migrations/0002_message_hidden.py
Executable file → Normal file
0
chat_box/migrations/0002_message_hidden.py
Executable file → Normal file
0
chat_box/migrations/0003_auto_20200505_2306.py
Executable file → Normal file
0
chat_box/migrations/0003_auto_20200505_2306.py
Executable file → Normal file
0
chat_box/migrations/0004_auto_20200505_2336.py
Executable file → Normal file
0
chat_box/migrations/0004_auto_20200505_2336.py
Executable file → Normal file
0
chat_box/migrations/0005_auto_20211011_0714.py
Executable file → Normal file
0
chat_box/migrations/0005_auto_20211011_0714.py
Executable file → Normal file
0
chat_box/migrations/0006_userroom.py
Executable file → Normal file
0
chat_box/migrations/0006_userroom.py
Executable file → Normal file
0
chat_box/migrations/0007_auto_20211112_1255.py
Executable file → Normal file
0
chat_box/migrations/0007_auto_20211112_1255.py
Executable file → Normal file
0
chat_box/migrations/0008_ignore.py
Executable file → Normal file
0
chat_box/migrations/0008_ignore.py
Executable file → Normal file
0
chat_box/migrations/0009_auto_20220618_1452.py
Executable file → Normal file
0
chat_box/migrations/0009_auto_20220618_1452.py
Executable file → Normal file
0
chat_box/migrations/0010_auto_20221028_0300.py
Executable file → Normal file
0
chat_box/migrations/0010_auto_20221028_0300.py
Executable file → Normal file
0
chat_box/migrations/0011_alter_message_hidden.py
Executable file → Normal file
0
chat_box/migrations/0011_alter_message_hidden.py
Executable file → Normal file
0
chat_box/migrations/0012_auto_20230308_1417.py
Executable file → Normal file
0
chat_box/migrations/0012_auto_20230308_1417.py
Executable file → Normal file
0
chat_box/migrations/__init__.py
Executable file → Normal file
0
chat_box/migrations/__init__.py
Executable file → Normal file
0
chat_box/models.py
Executable file → Normal file
0
chat_box/models.py
Executable file → Normal file
0
chat_box/utils.py
Executable file → Normal file
0
chat_box/utils.py
Executable file → Normal file
0
chat_box/views.py
Executable file → Normal file
0
chat_box/views.py
Executable file → Normal file
0
django_2_2_pymysql_patch.py
Executable file → Normal file
0
django_2_2_pymysql_patch.py
Executable file → Normal file
0
django_ace/__init__.py
Executable file → Normal file
0
django_ace/__init__.py
Executable file → Normal file
0
django_ace/static/django_ace/img/contract.png
Executable file → Normal file
0
django_ace/static/django_ace/img/contract.png
Executable file → Normal file
Before Width: | Height: | Size: 304 B After Width: | Height: | Size: 304 B |
0
django_ace/static/django_ace/img/expand.png
Executable file → Normal file
0
django_ace/static/django_ace/img/expand.png
Executable file → Normal file
Before Width: | Height: | Size: 285 B After Width: | Height: | Size: 285 B |
0
django_ace/static/django_ace/widget.css
Executable file → Normal file
0
django_ace/static/django_ace/widget.css
Executable file → Normal file
0
django_ace/static/django_ace/widget.js
Executable file → Normal file
0
django_ace/static/django_ace/widget.js
Executable file → Normal file
0
django_ace/widgets.py
Executable file → Normal file
0
django_ace/widgets.py
Executable file → Normal file
0
dmoj/__init__.py
Executable file → Normal file
0
dmoj/__init__.py
Executable file → Normal file
0
dmoj/celery.py
Executable file → Normal file
0
dmoj/celery.py
Executable file → Normal file
15
dmoj/settings.py
Executable file → Normal file
15
dmoj/settings.py
Executable file → Normal file
|
@ -219,7 +219,6 @@ else:
|
||||||
}
|
}
|
||||||
|
|
||||||
INSTALLED_APPS += (
|
INSTALLED_APPS += (
|
||||||
"debug_toolbar",
|
|
||||||
"django.contrib.admin",
|
"django.contrib.admin",
|
||||||
"judge",
|
"judge",
|
||||||
"django.contrib.auth",
|
"django.contrib.auth",
|
||||||
|
@ -249,7 +248,6 @@ INSTALLED_APPS += (
|
||||||
)
|
)
|
||||||
|
|
||||||
MIDDLEWARE = (
|
MIDDLEWARE = (
|
||||||
"debug_toolbar.middleware.DebugToolbarMiddleware",
|
|
||||||
"judge.middleware.SlowRequestMiddleware",
|
"judge.middleware.SlowRequestMiddleware",
|
||||||
"judge.middleware.ShortCircuitMiddleware",
|
"judge.middleware.ShortCircuitMiddleware",
|
||||||
"django.contrib.sessions.middleware.SessionMiddleware",
|
"django.contrib.sessions.middleware.SessionMiddleware",
|
||||||
|
@ -423,12 +421,7 @@ STATICFILES_DIRS = [
|
||||||
STATIC_URL = "/static/"
|
STATIC_URL = "/static/"
|
||||||
|
|
||||||
# Define a cache
|
# Define a cache
|
||||||
CACHES = {
|
CACHES = {}
|
||||||
"default": {
|
|
||||||
"BACKEND": "django.core.cache.backends.memcached.PyMemcacheCache",
|
|
||||||
"LOCATION": "127.0.0.1:11211",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Authentication
|
# Authentication
|
||||||
AUTHENTICATION_BACKENDS = (
|
AUTHENTICATION_BACKENDS = (
|
||||||
|
@ -488,9 +481,3 @@ except IOError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
DEFAULT_AUTO_FIELD = "django.db.models.AutoField"
|
DEFAULT_AUTO_FIELD = "django.db.models.AutoField"
|
||||||
|
|
||||||
INTERNAL_IPS = [
|
|
||||||
# ...
|
|
||||||
"127.0.0.1",
|
|
||||||
# ...
|
|
||||||
]
|
|
||||||
|
|
0
dmoj/throttle_mail.py
Executable file → Normal file
0
dmoj/throttle_mail.py
Executable file → Normal file
4
dmoj/urls.py
Executable file → Normal file
4
dmoj/urls.py
Executable file → Normal file
|
@ -1,6 +1,5 @@
|
||||||
import chat_box.views as chat
|
import chat_box.views as chat
|
||||||
|
|
||||||
from django.urls import include, path
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.conf.urls import include, url
|
from django.conf.urls import include, url
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
|
@ -207,7 +206,6 @@ def paged_list_view(view, name, **kwargs):
|
||||||
|
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('__debug__/', include('debug_toolbar.urls')),
|
|
||||||
url("", include("pagedown.urls")),
|
url("", include("pagedown.urls")),
|
||||||
url(
|
url(
|
||||||
r"^$",
|
r"^$",
|
||||||
|
@ -470,8 +468,6 @@ urlpatterns = [
|
||||||
url(r"^comments/upvote/$", comment.upvote_comment, name="comment_upvote"),
|
url(r"^comments/upvote/$", comment.upvote_comment, name="comment_upvote"),
|
||||||
url(r"^comments/downvote/$", comment.downvote_comment, name="comment_downvote"),
|
url(r"^comments/downvote/$", comment.downvote_comment, name="comment_downvote"),
|
||||||
url(r"^comments/hide/$", comment.comment_hide, name="comment_hide"),
|
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(
|
url(
|
||||||
r"^comments/(?P<id>\d+)/",
|
r"^comments/(?P<id>\d+)/",
|
||||||
include(
|
include(
|
||||||
|
|
0
dmoj/wsgi.py
Executable file → Normal file
0
dmoj/wsgi.py
Executable file → Normal file
0
dmoj/wsgi_async.py
Executable file → Normal file
0
dmoj/wsgi_async.py
Executable file → Normal file
0
dmoj_bridge_async.py
Executable file → Normal file
0
dmoj_bridge_async.py
Executable file → Normal file
0
dmoj_celery.py
Executable file → Normal file
0
dmoj_celery.py
Executable file → Normal file
0
dmoj_install_pymysql.py
Executable file → Normal file
0
dmoj_install_pymysql.py
Executable file → Normal file
0
judge/__init__.py
Executable file → Normal file
0
judge/__init__.py
Executable file → Normal file
0
judge/admin/__init__.py
Executable file → Normal file
0
judge/admin/__init__.py
Executable file → Normal file
0
judge/admin/comments.py
Executable file → Normal file
0
judge/admin/comments.py
Executable file → Normal file
0
judge/admin/contest.py
Executable file → Normal file
0
judge/admin/contest.py
Executable file → Normal file
0
judge/admin/interface.py
Executable file → Normal file
0
judge/admin/interface.py
Executable file → Normal file
0
judge/admin/organization.py
Executable file → Normal file
0
judge/admin/organization.py
Executable file → Normal file
0
judge/admin/problem.py
Executable file → Normal file
0
judge/admin/problem.py
Executable file → Normal file
0
judge/admin/profile.py
Executable file → Normal file
0
judge/admin/profile.py
Executable file → Normal file
0
judge/admin/runtime.py
Executable file → Normal file
0
judge/admin/runtime.py
Executable file → Normal file
0
judge/admin/submission.py
Executable file → Normal file
0
judge/admin/submission.py
Executable file → Normal file
0
judge/admin/taxon.py
Executable file → Normal file
0
judge/admin/taxon.py
Executable file → Normal file
0
judge/admin/ticket.py
Executable file → Normal file
0
judge/admin/ticket.py
Executable file → Normal file
0
judge/admin/volunteer.py
Executable file → Normal file
0
judge/admin/volunteer.py
Executable file → Normal file
0
judge/apps.py
Executable file → Normal file
0
judge/apps.py
Executable file → Normal file
0
judge/bridge/__init__.py
Executable file → Normal file
0
judge/bridge/__init__.py
Executable file → Normal file
0
judge/bridge/base_handler.py
Executable file → Normal file
0
judge/bridge/base_handler.py
Executable file → Normal file
0
judge/bridge/daemon.py
Executable file → Normal file
0
judge/bridge/daemon.py
Executable file → Normal file
0
judge/bridge/django_handler.py
Executable file → Normal file
0
judge/bridge/django_handler.py
Executable file → Normal file
0
judge/bridge/echo_test_client.py
Executable file → Normal file
0
judge/bridge/echo_test_client.py
Executable file → Normal file
0
judge/bridge/echo_test_server.py
Executable file → Normal file
0
judge/bridge/echo_test_server.py
Executable file → Normal file
0
judge/bridge/judge_handler.py
Executable file → Normal file
0
judge/bridge/judge_handler.py
Executable file → Normal file
0
judge/bridge/judge_list.py
Executable file → Normal file
0
judge/bridge/judge_list.py
Executable file → Normal file
0
judge/bridge/server.py
Executable file → Normal file
0
judge/bridge/server.py
Executable file → Normal file
0
judge/caching.py
Executable file → Normal file
0
judge/caching.py
Executable file → Normal file
65
judge/comments.py
Executable file → Normal file
65
judge/comments.py
Executable file → Normal file
|
@ -11,7 +11,6 @@ from django.http import (
|
||||||
HttpResponseForbidden,
|
HttpResponseForbidden,
|
||||||
HttpResponseNotFound,
|
HttpResponseNotFound,
|
||||||
HttpResponseRedirect,
|
HttpResponseRedirect,
|
||||||
Http404,
|
|
||||||
)
|
)
|
||||||
from django.urls import reverse_lazy
|
from django.urls import reverse_lazy
|
||||||
from django.utils.decorators import method_decorator
|
from django.utils.decorators import method_decorator
|
||||||
|
@ -152,92 +151,40 @@ class CommentedDetailView(TemplateResponseMixin, SingleObjectMixin, View):
|
||||||
return self.render_to_response(context)
|
return self.render_to_response(context)
|
||||||
|
|
||||||
def get(self, request, *args, **kwargs):
|
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()
|
self.object = self.get_object()
|
||||||
return self.render_to_response(
|
return self.render_to_response(
|
||||||
self.get_context_data(
|
self.get_context_data(
|
||||||
object=self.object,
|
object=self.object,
|
||||||
pre_query=pre_query,
|
|
||||||
comment_form=CommentForm(request, initial={"parent": None}),
|
comment_form=CommentForm(request, initial={"parent": None}),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
def get_context_data(self, pre_query=None, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super(CommentedDetailView, self).get_context_data(**kwargs)
|
context = super(CommentedDetailView, self).get_context_data(**kwargs)
|
||||||
queryset = self.object.comments
|
queryset = self.object.comments
|
||||||
queryset = queryset.filter(parent=None, hidden=False)
|
context["has_comments"] = queryset.exists()
|
||||||
queryset_all = None
|
context["comment_lock"] = self.is_comment_locked()
|
||||||
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 = (
|
||||||
queryset.select_related("author__user")
|
queryset.select_related("author__user")
|
||||||
.defer("author__about")
|
|
||||||
.filter(hidden=False)
|
.filter(hidden=False)
|
||||||
.annotate(
|
.defer("author__about")
|
||||||
count_replies=Count("replies", distinct=True),
|
.annotate(revisions=Count("versions"))
|
||||||
revisions=Count("versions", distinct=True),
|
|
||||||
)[:10]
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if self.request.user.is_authenticated:
|
if self.request.user.is_authenticated:
|
||||||
profile = self.request.profile
|
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(
|
queryset = queryset.annotate(
|
||||||
my_vote=FilteredRelation(
|
my_vote=FilteredRelation(
|
||||||
"votes", condition=Q(votes__voter_id=profile.id)
|
"votes", condition=Q(votes__voter_id=profile.id)
|
||||||
),
|
),
|
||||||
).annotate(vote_score=Coalesce(F("my_vote__score"), Value(0)))
|
).annotate(vote_score=Coalesce(F("my_vote__score"), Value(0)))
|
||||||
|
|
||||||
context["is_new_user"] = (
|
context["is_new_user"] = (
|
||||||
not self.request.user.is_staff
|
not self.request.user.is_staff
|
||||||
and not profile.submission_set.filter(
|
and not profile.submission_set.filter(
|
||||||
points=F("problem__points")
|
points=F("problem__points")
|
||||||
).exists()
|
).exists()
|
||||||
)
|
)
|
||||||
|
|
||||||
context["has_comments"] = queryset.exists()
|
|
||||||
context["comment_lock"] = self.is_comment_locked()
|
|
||||||
context["comment_list"] = queryset
|
context["comment_list"] = queryset
|
||||||
context["comment_all_list"] = queryset_all
|
context["comment_count"] = len(queryset)
|
||||||
|
|
||||||
context["vote_hide_threshold"] = settings.DMOJ_COMMENT_VOTE_HIDE_THRESHOLD
|
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
|
return context
|
||||||
|
|
0
judge/contest_format/__init__.py
Executable file → Normal file
0
judge/contest_format/__init__.py
Executable file → Normal file
0
judge/contest_format/atcoder.py
Executable file → Normal file
0
judge/contest_format/atcoder.py
Executable file → Normal file
0
judge/contest_format/base.py
Executable file → Normal file
0
judge/contest_format/base.py
Executable file → Normal file
0
judge/contest_format/default.py
Executable file → Normal file
0
judge/contest_format/default.py
Executable file → Normal file
0
judge/contest_format/ecoo.py
Executable file → Normal file
0
judge/contest_format/ecoo.py
Executable file → Normal file
0
judge/contest_format/icpc.py
Executable file → Normal file
0
judge/contest_format/icpc.py
Executable file → Normal file
0
judge/contest_format/ioi.py
Executable file → Normal file
0
judge/contest_format/ioi.py
Executable file → Normal file
0
judge/contest_format/new_ioi.py
Executable file → Normal file
0
judge/contest_format/new_ioi.py
Executable file → Normal file
0
judge/contest_format/registry.py
Executable file → Normal file
0
judge/contest_format/registry.py
Executable file → Normal file
0
judge/dblock.py
Executable file → Normal file
0
judge/dblock.py
Executable file → Normal file
0
judge/event_poster.py
Executable file → Normal file
0
judge/event_poster.py
Executable file → Normal file
0
judge/event_poster_amqp.py
Executable file → Normal file
0
judge/event_poster_amqp.py
Executable file → Normal file
0
judge/event_poster_ws.py
Executable file → Normal file
0
judge/event_poster_ws.py
Executable file → Normal file
0
judge/feed.py
Executable file → Normal file
0
judge/feed.py
Executable file → Normal file
0
judge/fixtures/demo.json
Executable file → Normal file
0
judge/fixtures/demo.json
Executable file → Normal file
0
judge/fixtures/language_small.json
Executable file → Normal file
0
judge/fixtures/language_small.json
Executable file → Normal file
0
judge/fixtures/navbar.json
Executable file → Normal file
0
judge/fixtures/navbar.json
Executable file → Normal file
0
judge/forms.py
Executable file → Normal file
0
judge/forms.py
Executable file → Normal file
0
judge/fulltext.py
Executable file → Normal file
0
judge/fulltext.py
Executable file → Normal file
0
judge/highlight_code.py
Executable file → Normal file
0
judge/highlight_code.py
Executable file → Normal file
0
judge/jinja2/__init__.py
Executable file → Normal file
0
judge/jinja2/__init__.py
Executable file → Normal file
0
judge/jinja2/camo.py
Executable file → Normal file
0
judge/jinja2/camo.py
Executable file → Normal file
0
judge/jinja2/chat.py
Executable file → Normal file
0
judge/jinja2/chat.py
Executable file → Normal file
0
judge/jinja2/datetime.py
Executable file → Normal file
0
judge/jinja2/datetime.py
Executable file → Normal file
0
judge/jinja2/filesize.py
Executable file → Normal file
0
judge/jinja2/filesize.py
Executable file → Normal file
0
judge/jinja2/gravatar.py
Executable file → Normal file
0
judge/jinja2/gravatar.py
Executable file → Normal file
0
judge/jinja2/language.py
Executable file → Normal file
0
judge/jinja2/language.py
Executable file → Normal file
0
judge/jinja2/markdown/__init__.py
Executable file → Normal file
0
judge/jinja2/markdown/__init__.py
Executable file → Normal file
0
judge/jinja2/rating.py
Executable file → Normal file
0
judge/jinja2/rating.py
Executable file → Normal file
0
judge/jinja2/reference.py
Executable file → Normal file
0
judge/jinja2/reference.py
Executable file → Normal file
0
judge/jinja2/registry.py
Executable file → Normal file
0
judge/jinja2/registry.py
Executable file → Normal file
0
judge/jinja2/render.py
Executable file → Normal file
0
judge/jinja2/render.py
Executable file → Normal file
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue