mirror of
https://github.com/QingdaoU/OnlineJudge.git
synced 2024-09-21 00:13:18 +00:00
设置是否显示全部的提交列表
This commit is contained in:
parent
a3ca1bb22e
commit
4e6465ff26
@ -184,3 +184,6 @@ TOKEN_BUCKET_DEFAULT_CAPACITY = 50
|
|||||||
|
|
||||||
# 单位:每分钟
|
# 单位:每分钟
|
||||||
TOKEN_BUCKET_FILL_RATE = 2
|
TOKEN_BUCKET_FILL_RATE = 2
|
||||||
|
|
||||||
|
# 是否显示所有人的提交, False就只显示自己的
|
||||||
|
SHOW_ALL_SUBMISSIONS_LIST = False
|
||||||
|
@ -242,8 +242,8 @@ def my_submission_list_page(request, page=1):
|
|||||||
"""
|
"""
|
||||||
我的所有提交的列表页
|
我的所有提交的列表页
|
||||||
"""
|
"""
|
||||||
# 显示所有人的提交 这是管理员的调试功能
|
# 是否显示所有人的提交
|
||||||
show_all = request.GET.get("show_all", False) == "true" and request.user.admin_type == SUPER_ADMIN
|
show_all = settings.SHOW_ALL_SUBMISSIONS_LIST or request.GET.get("show_all", False) == "true"
|
||||||
if show_all:
|
if show_all:
|
||||||
submissions = Submission.objects.filter(contest_id__isnull=True)
|
submissions = Submission.objects.filter(contest_id__isnull=True)
|
||||||
else:
|
else:
|
||||||
@ -261,6 +261,12 @@ def my_submission_list_page(request, page=1):
|
|||||||
submissions = submissions.filter(result=int(result))
|
submissions = submissions.filter(result=int(result))
|
||||||
filter = {"name": "result", "content": result}
|
filter = {"name": "result", "content": result}
|
||||||
|
|
||||||
|
paginator = Paginator(submissions, 20)
|
||||||
|
try:
|
||||||
|
submissions = paginator.page(int(page))
|
||||||
|
except Exception:
|
||||||
|
return error_page(request, u"不存在的页码")
|
||||||
|
|
||||||
# 因为提交页面经常会有重复的题目和用户,缓存一下查询结果
|
# 因为提交页面经常会有重复的题目和用户,缓存一下查询结果
|
||||||
cache_result = {"problem": {}, "user": {}}
|
cache_result = {"problem": {}, "user": {}}
|
||||||
for item in submissions:
|
for item in submissions:
|
||||||
@ -277,23 +283,23 @@ def my_submission_list_page(request, page=1):
|
|||||||
cache_result["user"][user_id] = user
|
cache_result["user"][user_id] = user
|
||||||
item["user"] = cache_result["user"][user_id]
|
item["user"] = cache_result["user"][user_id]
|
||||||
|
|
||||||
paginator = Paginator(submissions, 20)
|
if item["user"].id == request.user.id or request.user.admin_type == SUPER_ADMIN:
|
||||||
try:
|
item["show_link"] = True
|
||||||
current_page = paginator.page(int(page))
|
else:
|
||||||
except Exception:
|
item["show_link"] = False
|
||||||
return error_page(request, u"不存在的页码")
|
|
||||||
previous_page = next_page = None
|
previous_page = next_page = None
|
||||||
try:
|
try:
|
||||||
previous_page = current_page.previous_page_number()
|
previous_page = submissions.previous_page_number()
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
try:
|
try:
|
||||||
next_page = current_page.next_page_number()
|
next_page = submissions.next_page_number()
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
return render(request, "oj/submission/my_submissions_list.html",
|
return render(request, "oj/submission/my_submissions_list.html",
|
||||||
{"submissions": current_page, "page": int(page),
|
{"submissions": submissions, "page": int(page),
|
||||||
"previous_page": previous_page, "next_page": next_page, "start_id": int(page) * 20 - 20,
|
"previous_page": previous_page, "next_page": next_page, "start_id": int(page) * 20 - 20,
|
||||||
"filter": filter, "show_all": show_all})
|
"filter": filter, "show_all": show_all})
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>#</th>
|
<th>#</th>
|
||||||
|
{% if show_all %}<th>用户</th>{% endif %}
|
||||||
<th>题目名称</th>
|
<th>题目名称</th>
|
||||||
<th>提交时间</th>
|
<th>提交时间</th>
|
||||||
<th>
|
<th>
|
||||||
@ -51,9 +52,13 @@
|
|||||||
{% for item in submissions %}
|
{% for item in submissions %}
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row">
|
<th scope="row">
|
||||||
<a href="/submission/{{ item.id }}/">{{ forloop.counter |add:start_id }}</a>
|
{% if item.show_link %}
|
||||||
{% if show_all %}({{ item.user.username }}){% endif %}
|
<a href="/submission/{{ item.id }}/">{{ forloop.counter |add:start_id }}</a>
|
||||||
|
{% else %}
|
||||||
|
{{ forloop.counter |add:start_id }}
|
||||||
|
{% endif %}
|
||||||
</th>
|
</th>
|
||||||
|
{% if show_all %}<td><a href="/user/{{ item.user.username }}">{{ item.user.username }}</a></td>{% endif %}
|
||||||
<td>
|
<td>
|
||||||
<a href="/problem/{{ item.problem_id }}/">{{ item.title }}</a>
|
<a href="/problem/{{ item.problem_id }}/">{{ item.title }}</a>
|
||||||
</td>
|
</td>
|
||||||
|
Loading…
Reference in New Issue
Block a user