This reverts commit 0494a36681
.
This commit is contained in:
parent
0494a36681
commit
da2a11adf9
784 changed files with 696 additions and 307 deletions
0
judge/__init__.py
Normal file → Executable file
0
judge/__init__.py
Normal file → Executable file
0
judge/admin/__init__.py
Normal file → Executable file
0
judge/admin/__init__.py
Normal file → Executable file
0
judge/admin/comments.py
Normal file → Executable file
0
judge/admin/comments.py
Normal file → Executable file
0
judge/admin/contest.py
Normal file → Executable file
0
judge/admin/contest.py
Normal file → Executable file
0
judge/admin/interface.py
Normal file → Executable file
0
judge/admin/interface.py
Normal file → Executable file
0
judge/admin/organization.py
Normal file → Executable file
0
judge/admin/organization.py
Normal file → Executable file
0
judge/admin/problem.py
Normal file → Executable file
0
judge/admin/problem.py
Normal file → Executable file
0
judge/admin/profile.py
Normal file → Executable file
0
judge/admin/profile.py
Normal file → Executable file
0
judge/admin/runtime.py
Normal file → Executable file
0
judge/admin/runtime.py
Normal file → Executable file
0
judge/admin/submission.py
Normal file → Executable file
0
judge/admin/submission.py
Normal file → Executable file
0
judge/admin/taxon.py
Normal file → Executable file
0
judge/admin/taxon.py
Normal file → Executable file
0
judge/admin/ticket.py
Normal file → Executable file
0
judge/admin/ticket.py
Normal file → Executable file
0
judge/admin/volunteer.py
Normal file → Executable file
0
judge/admin/volunteer.py
Normal file → Executable file
0
judge/apps.py
Normal file → Executable file
0
judge/apps.py
Normal file → Executable file
0
judge/bridge/__init__.py
Normal file → Executable file
0
judge/bridge/__init__.py
Normal file → Executable file
0
judge/bridge/base_handler.py
Normal file → Executable file
0
judge/bridge/base_handler.py
Normal file → Executable file
0
judge/bridge/daemon.py
Normal file → Executable file
0
judge/bridge/daemon.py
Normal file → Executable file
0
judge/bridge/django_handler.py
Normal file → Executable file
0
judge/bridge/django_handler.py
Normal file → Executable file
0
judge/bridge/echo_test_client.py
Normal file → Executable file
0
judge/bridge/echo_test_client.py
Normal file → Executable file
0
judge/bridge/echo_test_server.py
Normal file → Executable file
0
judge/bridge/echo_test_server.py
Normal file → Executable file
0
judge/bridge/judge_handler.py
Normal file → Executable file
0
judge/bridge/judge_handler.py
Normal file → Executable file
0
judge/bridge/judge_list.py
Normal file → Executable file
0
judge/bridge/judge_list.py
Normal file → Executable file
0
judge/bridge/server.py
Normal file → Executable file
0
judge/bridge/server.py
Normal file → Executable file
0
judge/caching.py
Normal file → Executable file
0
judge/caching.py
Normal file → Executable file
85
judge/comments.py
Normal file → Executable file
85
judge/comments.py
Normal file → Executable 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
0
judge/contest_format/__init__.py
Normal file → Executable file
0
judge/contest_format/atcoder.py
Normal file → Executable file
0
judge/contest_format/atcoder.py
Normal file → Executable file
0
judge/contest_format/base.py
Normal file → Executable file
0
judge/contest_format/base.py
Normal file → Executable file
0
judge/contest_format/default.py
Normal file → Executable file
0
judge/contest_format/default.py
Normal file → Executable file
0
judge/contest_format/ecoo.py
Normal file → Executable file
0
judge/contest_format/ecoo.py
Normal file → Executable file
0
judge/contest_format/icpc.py
Normal file → Executable file
0
judge/contest_format/icpc.py
Normal file → Executable file
0
judge/contest_format/ioi.py
Normal file → Executable file
0
judge/contest_format/ioi.py
Normal file → Executable file
0
judge/contest_format/new_ioi.py
Normal file → Executable file
0
judge/contest_format/new_ioi.py
Normal file → Executable file
0
judge/contest_format/registry.py
Normal file → Executable file
0
judge/contest_format/registry.py
Normal file → Executable file
0
judge/dblock.py
Normal file → Executable file
0
judge/dblock.py
Normal file → Executable file
0
judge/event_poster.py
Normal file → Executable file
0
judge/event_poster.py
Normal file → Executable file
0
judge/event_poster_amqp.py
Normal file → Executable file
0
judge/event_poster_amqp.py
Normal file → Executable file
0
judge/event_poster_ws.py
Normal file → Executable file
0
judge/event_poster_ws.py
Normal file → Executable file
0
judge/feed.py
Normal file → Executable file
0
judge/feed.py
Normal file → Executable file
0
judge/fixtures/demo.json
Normal file → Executable file
0
judge/fixtures/demo.json
Normal file → Executable file
0
judge/fixtures/language_small.json
Normal file → Executable file
0
judge/fixtures/language_small.json
Normal file → Executable file
0
judge/fixtures/navbar.json
Normal file → Executable file
0
judge/fixtures/navbar.json
Normal file → Executable file
0
judge/forms.py
Normal file → Executable file
0
judge/forms.py
Normal file → Executable file
0
judge/fulltext.py
Normal file → Executable file
0
judge/fulltext.py
Normal file → Executable file
0
judge/highlight_code.py
Normal file → Executable file
0
judge/highlight_code.py
Normal file → Executable file
0
judge/jinja2/__init__.py
Normal file → Executable file
0
judge/jinja2/__init__.py
Normal file → Executable file
0
judge/jinja2/camo.py
Normal file → Executable file
0
judge/jinja2/camo.py
Normal file → Executable file
0
judge/jinja2/chat.py
Normal file → Executable file
0
judge/jinja2/chat.py
Normal file → Executable file
0
judge/jinja2/datetime.py
Normal file → Executable file
0
judge/jinja2/datetime.py
Normal file → Executable file
0
judge/jinja2/filesize.py
Normal file → Executable file
0
judge/jinja2/filesize.py
Normal file → Executable file
0
judge/jinja2/gravatar.py
Normal file → Executable file
0
judge/jinja2/gravatar.py
Normal file → Executable file
0
judge/jinja2/language.py
Normal file → Executable file
0
judge/jinja2/language.py
Normal file → Executable file
0
judge/jinja2/markdown/__init__.py
Normal file → Executable file
0
judge/jinja2/markdown/__init__.py
Normal file → Executable file
0
judge/jinja2/rating.py
Normal file → Executable file
0
judge/jinja2/rating.py
Normal file → Executable file
0
judge/jinja2/reference.py
Normal file → Executable file
0
judge/jinja2/reference.py
Normal file → Executable file
0
judge/jinja2/registry.py
Normal file → Executable file
0
judge/jinja2/registry.py
Normal file → Executable file
0
judge/jinja2/render.py
Normal file → Executable file
0
judge/jinja2/render.py
Normal file → Executable file
0
judge/jinja2/social.py
Normal file → Executable file
0
judge/jinja2/social.py
Normal file → Executable file
0
judge/jinja2/spaceless.py
Normal file → Executable file
0
judge/jinja2/spaceless.py
Normal file → Executable file
0
judge/jinja2/submission.py
Normal file → Executable file
0
judge/jinja2/submission.py
Normal file → Executable file
0
judge/jinja2/timedelta.py
Normal file → Executable file
0
judge/jinja2/timedelta.py
Normal file → Executable file
0
judge/judgeapi.py
Normal file → Executable file
0
judge/judgeapi.py
Normal file → Executable file
0
judge/lxml_tree.py
Normal file → Executable file
0
judge/lxml_tree.py
Normal file → Executable file
0
judge/management/__init__.py
Normal file → Executable file
0
judge/management/__init__.py
Normal file → Executable file
0
judge/management/commands/__init__.py
Normal file → Executable file
0
judge/management/commands/__init__.py
Normal file → Executable file
0
judge/management/commands/addjudge.py
Normal file → Executable file
0
judge/management/commands/addjudge.py
Normal file → Executable file
0
judge/management/commands/adduser.py
Normal file → Executable file
0
judge/management/commands/adduser.py
Normal file → Executable file
0
judge/management/commands/camo.py
Normal file → Executable file
0
judge/management/commands/camo.py
Normal file → Executable file
0
judge/management/commands/copy_language.py
Normal file → Executable file
0
judge/management/commands/copy_language.py
Normal file → Executable file
0
judge/management/commands/create_problem.py
Normal file → Executable file
0
judge/management/commands/create_problem.py
Normal file → Executable file
0
judge/management/commands/generate_data.py
Normal file → Executable file
0
judge/management/commands/generate_data.py
Normal file → Executable file
0
judge/management/commands/makedmojmessages.py
Normal file → Executable file
0
judge/management/commands/makedmojmessages.py
Normal file → Executable file
0
judge/management/commands/render_pdf.py
Normal file → Executable file
0
judge/management/commands/render_pdf.py
Normal file → Executable file
0
judge/management/commands/runbridged.py
Normal file → Executable file
0
judge/management/commands/runbridged.py
Normal file → Executable file
0
judge/management/commands/runmoss.py
Normal file → Executable file
0
judge/management/commands/runmoss.py
Normal file → Executable file
0
judge/middleware.py
Normal file → Executable file
0
judge/middleware.py
Normal file → Executable file
0
judge/migrations/0001_squashed_0084_contest_formats.py
Normal file → Executable file
0
judge/migrations/0001_squashed_0084_contest_formats.py
Normal file → Executable file
0
judge/migrations/0085_submission_source.py
Normal file → Executable file
0
judge/migrations/0085_submission_source.py
Normal file → Executable file
0
judge/migrations/0086_rating_ceiling.py
Normal file → Executable file
0
judge/migrations/0086_rating_ceiling.py
Normal file → Executable file
0
judge/migrations/0087_problem_resource_limits.py
Normal file → Executable file
0
judge/migrations/0087_problem_resource_limits.py
Normal file → Executable file
0
judge/migrations/0088_private_contests.py
Normal file → Executable file
0
judge/migrations/0088_private_contests.py
Normal file → Executable file
0
judge/migrations/0089_submission_to_contest.py
Normal file → Executable file
0
judge/migrations/0089_submission_to_contest.py
Normal file → Executable file
0
judge/migrations/0090_fix_contest_visibility.py
Normal file → Executable file
0
judge/migrations/0090_fix_contest_visibility.py
Normal file → Executable file
0
judge/migrations/0091_compiler_message_ansi2html.py
Normal file → Executable file
0
judge/migrations/0091_compiler_message_ansi2html.py
Normal file → Executable file
0
judge/migrations/0092_contest_clone.py
Normal file → Executable file
0
judge/migrations/0092_contest_clone.py
Normal file → Executable file
0
judge/migrations/0093_contest_moss.py
Normal file → Executable file
0
judge/migrations/0093_contest_moss.py
Normal file → Executable file
0
judge/migrations/0094_submissiontestcase_unique_together.py
Normal file → Executable file
0
judge/migrations/0094_submissiontestcase_unique_together.py
Normal file → Executable file
0
judge/migrations/0095_organization_logo_override.py
Normal file → Executable file
0
judge/migrations/0095_organization_logo_override.py
Normal file → Executable file
0
judge/migrations/0096_profile_language_set_default.py
Normal file → Executable file
0
judge/migrations/0096_profile_language_set_default.py
Normal file → Executable file
0
judge/migrations/0097_participation_is_disqualified.py
Normal file → Executable file
0
judge/migrations/0097_participation_is_disqualified.py
Normal file → Executable file
0
judge/migrations/0098_auto_20200123_2136.py
Normal file → Executable file
0
judge/migrations/0098_auto_20200123_2136.py
Normal file → Executable file
0
judge/migrations/0099_custom_checker.py
Normal file → Executable file
0
judge/migrations/0099_custom_checker.py
Normal file → Executable file
0
judge/migrations/0100_auto_20200127_0059.py
Normal file → Executable file
0
judge/migrations/0100_auto_20200127_0059.py
Normal file → Executable file
0
judge/migrations/0101_custom_validator.py
Normal file → Executable file
0
judge/migrations/0101_custom_validator.py
Normal file → Executable file
0
judge/migrations/0102_fix_custom_validator.py
Normal file → Executable file
0
judge/migrations/0102_fix_custom_validator.py
Normal file → Executable file
0
judge/migrations/0103_fix_custom_validator.py
Normal file → Executable file
0
judge/migrations/0103_fix_custom_validator.py
Normal file → Executable file
0
judge/migrations/0104_auto_20200410_1313.py
Normal file → Executable file
0
judge/migrations/0104_auto_20200410_1313.py
Normal file → Executable file
0
judge/migrations/0105_auto_20200523_0756.py
Normal file → Executable file
0
judge/migrations/0105_auto_20200523_0756.py
Normal file → Executable file
0
judge/migrations/0106_friend.py
Normal file → Executable file
0
judge/migrations/0106_friend.py
Normal file → Executable file
0
judge/migrations/0107_notification.py
Normal file → Executable file
0
judge/migrations/0107_notification.py
Normal file → Executable file
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue