mirror of
https://github.com/QingdaoU/OnlineJudge.git
synced 2024-09-21 16:33:22 +00:00
增加对比赛提交链接显示权限的判断
This commit is contained in:
parent
4a506939d1
commit
1957610239
@ -120,12 +120,15 @@ def contest_problem_submissions_list_page(request, contest_id, page=1):
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# 如果该用户是超级管理员那么他可以查看所有的提交记录详情
|
||||
if request.user.admin_type > 1:
|
||||
return render(request, "oj/contest/submissions_list_admin.html",
|
||||
{"submissions": current_page, "page": int(page),
|
||||
"previous_page": previous_page, "next_page": next_page, "start_id": int(page) * 20 - 20,
|
||||
"contest": contest})
|
||||
for item in current_page:
|
||||
if item.user_id == request.user.id:
|
||||
setattr(item, "show_link", True)
|
||||
elif request.user.admin_type == SUPER_ADMIN or request.user:
|
||||
setattr(item, "show_link", True)
|
||||
elif request.user == contest.created_by:
|
||||
setattr(item, "show_link", True)
|
||||
else:
|
||||
setattr(item, "show_link", False)
|
||||
|
||||
return render(request, "oj/contest/submissions_list.html",
|
||||
{"submissions": current_page, "page": int(page),
|
||||
|
@ -67,12 +67,13 @@
|
||||
<tbody>
|
||||
{% for item in submissions %}
|
||||
<tr>
|
||||
{% ifequal item.user_id request.user.id %}
|
||||
<th scope="row"><a href="/submission/{{ item.id }}/">
|
||||
{{ forloop.counter |add:start_id }}</a></th>
|
||||
<th scope="row">
|
||||
{% if item.show_link %}
|
||||
<a href="/submission/{{ item.id }}/">{{ forloop.counter |add:start_id }}</a>
|
||||
{% else %}
|
||||
<th scope="row">{{ forloop.counter |add:start_id }}</th>
|
||||
{% endifequal %}
|
||||
{{ forloop.counter |add:start_id }}
|
||||
{% endif %}
|
||||
</th>
|
||||
<th scope="row">
|
||||
<a href="/contest/{{ item.contest_id }}/problem/{{ item.problem_id }}/">{{ item.title }}</a>
|
||||
</th>
|
||||
|
@ -1,114 +0,0 @@
|
||||
{% extends 'oj_base.html' %}
|
||||
|
||||
{% block body %}
|
||||
|
||||
{% load submission %}
|
||||
{% load user %}
|
||||
<div class="container main">
|
||||
<div class="contest-tab">
|
||||
<ul class="nav nav-tabs nav-tabs-google">
|
||||
<li role="presentation">
|
||||
<a href="/contest/{{ contest.id }}/">比赛详情</a>
|
||||
</li>
|
||||
<li role="presentation">
|
||||
<a href="/contest/{{ contest.id }}/problems/">题目</a>
|
||||
</li>
|
||||
<li role="presentation" class="active">
|
||||
<a href="/contest/{{ contest.id }}/submissions/">提交</a>
|
||||
</li>
|
||||
<li role="presentation">
|
||||
<a href="/contest/{{ contest.id }}/rank/">排名</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<table class="table table-bordered">
|
||||
<thead>
|
||||
<tr class="" success>
|
||||
<th>#</th>
|
||||
<th>题目名称</th>
|
||||
<th>用户</th>
|
||||
<th>提交时间</th>
|
||||
<th>
|
||||
<div class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" id="languageFilter" data-toggle="dropdown"
|
||||
aria-haspopup="true" aria-expanded="true">
|
||||
语言<span class="caret"></span>
|
||||
</a>
|
||||
<ul class="dropdown-menu" aria-labelledby="languageFilter">
|
||||
<li><a href="/contest/{{ contest.id }}/submissions/?language=1">C</a></li>
|
||||
<li><a href="/contest/{{ contest.id }}/submissions/?language=2">C++</a></li>
|
||||
<li><a href="/contest/{{ contest.id }}/submissions/?language=3">Java</a></li>
|
||||
<li><a href="/contest/{{ contest.id }}/submissions/">取消筛选</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</th>
|
||||
<th>运行时间</th>
|
||||
<th>
|
||||
<div class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" id="resultFilter" data-toggle="dropdown"
|
||||
aria-haspopup="true" aria-expanded="true">
|
||||
结果<span class="caret"></span>
|
||||
</a>
|
||||
<ul class="dropdown-menu" aria-labelledby="resultFilter">
|
||||
<li><a href="/contest/{{ contest.id }}/submissions/?result=0">Accepted</a></li>
|
||||
<li><a href="/contest/{{ contest.id }}/submissions/?result=6">Wrong Answer</a></li>
|
||||
<li><a href="/contest/{{ contest.id }}/submissions/?result=1">Runtime Error</a></li>
|
||||
<li><a href="/contest/{{ contest.id }}/submissions/?result=2">Time Limit Exceeded</a></li>
|
||||
<li><a href="/contest/{{ contest.id }}/submissions/?result=3">Memory Limit Exceeded</a></li>
|
||||
<li><a href="/contest/{{ contest.id }}/submissions/?result=4">Compile Error</a></li>
|
||||
<li><a href="/contest/{{ contest.id }}/submissions/?result=5">Format Error</a></li>
|
||||
<li><a href="/contest/{{ contest.id }}/submissions/">取消筛选</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
{% if submissions %}
|
||||
<tbody>
|
||||
|
||||
{% for item in submissions %}
|
||||
<tr>
|
||||
<th scope="row"><a href="/submission/{{ item.id }}/">
|
||||
{{ forloop.counter |add:start_id }}</a></th>
|
||||
<th scope="row">
|
||||
<a href="/contest/{{ item.contest_id }}/problem/{{ item.problem_id }}/">{{ item.title }}</a>
|
||||
</th>
|
||||
<td>{{ item.user_id|get_username }}</td>
|
||||
<td>{{ item.create_time }}</td>
|
||||
<td>
|
||||
{{ item.language|translate_language }}
|
||||
</td>
|
||||
<td>
|
||||
{% if item.accepted_answer_time %}
|
||||
{{ item.accepted_answer_time }}ms
|
||||
{% else %}
|
||||
--
|
||||
{% endif %}
|
||||
</td>
|
||||
<td class="alert-{{ item.result|translate_result_class }}">
|
||||
<strong>{{ item.result|translate_result }}</strong>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
{% else %}
|
||||
<p>本场比赛还没有提交记录</p>
|
||||
{% endif %}
|
||||
</table>
|
||||
|
||||
<nav>
|
||||
<ul class="pager">
|
||||
{% if previous_page %}
|
||||
<li class="previous"><a
|
||||
href="/contest/{{ contest.id }}/submissions/{{ previous_page }}/{% if filter %}?{{ filter.name }}={{ filter.content }}{% endif %}">
|
||||
<span aria-hidden="true">←</span> 上一页</a></li>
|
||||
{% endif %}
|
||||
{% if next_page %}
|
||||
<li class="next">
|
||||
<a href="/contest/{{ contest.id }}/submissions/{{ next_page }}/{% if filter %}?{{ filter.name }}={{ filter.content }}{% endif %}">
|
||||
下一页 <span aria-hidden="true">→</span></a></li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
</nav>
|
||||
</div>
|
||||
{% endblock %}
|
Loading…
Reference in New Issue
Block a user