mirror of
https://github.com/QingdaoU/OnlineJudge.git
synced 2025-11-04 14:49:58 +08:00
增加显示所有提交的调试功能
This commit is contained in:
parent
0e50f7fdc5
commit
5ac16a3c7f
@ -11,7 +11,7 @@ from rest_framework.views import APIView
|
||||
from judge.judger_controller.tasks import judge
|
||||
from judge.judger_controller.settings import redis_config
|
||||
from account.decorators import login_required
|
||||
from account.models import SUPER_ADMIN
|
||||
from account.models import SUPER_ADMIN, User
|
||||
|
||||
from problem.models import Problem
|
||||
from contest.models import ContestProblem, Contest
|
||||
@ -162,7 +162,11 @@ def my_submission_list_page(request, page=1):
|
||||
我的所有提交的列表页
|
||||
"""
|
||||
submissions = Submission.objects.filter(user_id=request.user.id, contest_id__isnull=True). \
|
||||
values("id", "problem_id", "result", "create_time", "accepted_answer_time", "language").order_by("-create_time")
|
||||
values("id", "user_id", "problem_id", "result", "create_time", "accepted_answer_time", "language").order_by("-create_time")
|
||||
|
||||
# 显示所有人的提交 这是管理员的调试功能
|
||||
show_all = request.GET.get("show_all", False) == "true"
|
||||
|
||||
language = request.GET.get("language", None)
|
||||
filter = None
|
||||
if language:
|
||||
@ -173,14 +177,21 @@ def my_submission_list_page(request, page=1):
|
||||
submissions = submissions.filter(result=int(result))
|
||||
filter = {"name": "result", "content": result}
|
||||
|
||||
# 为 submission 查询题目 因为提交页面经常会有重复的题目,缓存一下查询结果
|
||||
cache_result = {}
|
||||
# 因为提交页面经常会有重复的题目和用户,缓存一下查询结果
|
||||
cache_result = {"problem": {}, "user": {}}
|
||||
for item in submissions:
|
||||
problem_id = item["problem_id"]
|
||||
if problem_id not in cache_result:
|
||||
if problem_id not in cache_result["problem"]:
|
||||
problem = Problem.objects.get(id=problem_id)
|
||||
cache_result[problem_id] = problem.title
|
||||
item["title"] = cache_result[problem_id]
|
||||
cache_result["problem"][problem_id] = problem.title
|
||||
item["title"] = cache_result["problem"][problem_id]
|
||||
|
||||
if show_all:
|
||||
user_id = item["user_id"]
|
||||
if user_id not in cache_result["user"]:
|
||||
user = User.objects.get(id=user_id)
|
||||
cache_result["user"][user_id] = user
|
||||
item["user"] = cache_result["user"][user_id]
|
||||
|
||||
paginator = Paginator(submissions, 20)
|
||||
try:
|
||||
@ -197,13 +208,10 @@ def my_submission_list_page(request, page=1):
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# 右侧的公告列表
|
||||
announcements = Announcement.objects.filter(is_global=True, visible=True).order_by("-create_time")
|
||||
|
||||
return render(request, "oj/submission/my_submissions_list.html",
|
||||
{"submissions": current_page, "page": int(page),
|
||||
"previous_page": previous_page, "next_page": next_page, "start_id": int(page) * 20 - 20,
|
||||
"announcements": announcements, "filter": filter})
|
||||
"filter": filter, "show_all": show_all})
|
||||
|
||||
|
||||
class SubmissionShareAPIView(APIView):
|
||||
|
||||
@ -27,7 +27,10 @@
|
||||
<tbody>
|
||||
{% for item in submissions %}
|
||||
<tr>
|
||||
<th scope="row"><a href="/submission/{{ item.id }}/">{{ forloop.counter }}</a></th>
|
||||
<th scope="row">
|
||||
<a href="/submission/{{ item.id }}/">{{ forloop.counter }}</a>
|
||||
{% if show_all %}{{ item.user.username }}{% endif %}
|
||||
</th>
|
||||
<td>{{ item.create_time }}</td>
|
||||
<td>
|
||||
{{ item.language|translate_language }}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user