整理格式,增加提交列表的用户名

This commit is contained in:
virusdefender
2015-08-25 10:57:09 +08:00
parent c5d5aa87c4
commit 4adb1c0b0c
3 changed files with 97 additions and 75 deletions

View File

@@ -41,10 +41,11 @@
{% for item in contest_problems %} {% for item in contest_problems %}
<tr> <tr>
<th><span class="glyphicon glyphicon-ok ac-flag"></span></th> <th><span class="glyphicon glyphicon-ok ac-flag"></span></th>
<th scope="row"><a <th scope="row">
href="/contest/{{ item.contest.id }}/problem/{{ item.id }}/">{{ item.sort_index }}</a> <a href="/contest/{{ item.contest.id }}/problem/{{ item.id }}/" target="_blank">{{ item.sort_index }}</a>
</th> </th>
<td><a href="/contest/{{ item.contest.id }}/problem/{{ item.id }}/">{{ item.title }}</a> <td>
<a href="/contest/{{ item.contest.id }}/problem/{{ item.id }}/" target="_blank">{{ item.title }}</a>
</td> </td>
<td>{{ item|accepted_radio }}</td> <td>{{ item|accepted_radio }}</td>
</tr> </tr>

View File

@@ -2,79 +2,83 @@
{% block body %} {% block body %}
{% load submission %} {% load submission %}
<div class="container main"> {% load user %}
<div class="contest-tab"> <div class="container main">
<ul class="nav nav-tabs nav-tabs-google"> <div class="contest-tab">
<li role="presentation"> <ul class="nav nav-tabs nav-tabs-google">
<a href="/contest/{{ contest.id }}/">比赛详情</a> <li role="presentation">
</li> <a href="/contest/{{ contest.id }}/">比赛详情</a>
<li role="presentation"> </li>
<a href="/contest/{{ contest.id }}/problems/">题目</a> <li role="presentation">
</li> <a href="/contest/{{ contest.id }}/problems/">题目</a>
<li role="presentation" class="active"> </li>
<a href="/contest/{{ contest.id }}/submissions/">提交</a> <li role="presentation" class="active">
</li> <a href="/contest/{{ contest.id }}/submissions/">提交</a>
<li role="presentation"> </li>
<a href="/contest/{{ contest.id }}/rank/">排名</a> <li role="presentation">
</li> <a href="/contest/{{ contest.id }}/rank/">排名</a>
</ul> </li>
</div> </ul>
{% if submissions %} </div>
<table class="table table-bordered"> {% if submissions %}
<thead> <table class="table table-bordered">
<tr class="" success> <thead>
<th>#</th> <tr class="" success>
<th>提交时间</th> <th>#</th>
<th>结果</th> <td>用户</td>
<th>运行时间</th> <th>提交时间</th>
<th>语言</th> <th>结果</th>
</tr> <th>运行时间</th>
</thead> <th>语言</th>
<tbody> </tr>
{% for item in submissions %} </thead>
<tr class="{{ item.result|translate_result_class }}"> <tbody>
{% for item in submissions %}
<tr class="{{ item.result|translate_result_class }}">
{% ifequal item.user_id request.user.id %} {% ifequal item.user_id request.user.id %}
<th scope="row"><a href="/submission/{{ item.id }}/" id="id_{{ forloop.counter }}"> <th scope="row"><a href="/submission/{{ item.id }}/" id="id_{{ forloop.counter }}">
{{ forloop.counter |add:start_id }}</a></th> {{ forloop.counter |add:start_id }}</a></th>
{% else %} {% else %}
<th scope="row">{{ forloop.counter |add:start_id }}</th> <th scope="row">{{ forloop.counter |add:start_id }}</th>
{% endifequal %} {% endifequal %}
<td>{{ item.create_time }}</td> <td>{{ item.user_id|get_username }}</td>
<td>{{ item.result|translate_result }}</td>
<td> <td>{{ item.create_time }}</td>
{% if item.accepted_answer_time %} <td>{{ item.result|translate_result }}</td>
{{ item.accepted_answer_time }}ms <td>
{% else %} {% if item.accepted_answer_time %}
-- {{ item.accepted_answer_time }}ms
{% else %}
--
{% endif %}
</td>
<td>
{{ item.language|translate_language }}
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<p>你还没有提交记录!</p>
{% endif %}
<nav>
<ul class="pager">
{% if previous_page %}
<li class="previous"><a
href="/contest/{{ contest.id }}/submissions/{{ previous_page }}/">
<span aria-hidden="true">&larr;</span> 上一页</a></li>
{% endif %} {% endif %}
</td> {% if next_page %}
<td> <li class="next">
{{ item.language|translate_language }} <a href="/contest/{{ contest.id }}/submissions/{{ next_page }}/">下一页 <span
</td> aria-hidden="true">&rarr;</span></a></li>
</tr> {% endif %}
{% endfor %} </ul>
</nav>
</tbody> </div>
</table>
{% else %}
<p>你还没有提交记录!</p>
{% endif %}
<nav>
<ul class="pager">
{% if previous_page %}
<li class="previous"><a
href="/contest/{{ contest.id }}/submissions/{{ previous_page }}/">
<span aria-hidden="true">&larr;</span> 上一页</a></li>
{% endif %}
{% if next_page %}
<li class="next">
<a href="/contest/{{ contest.id }}/submissions/{{ next_page }}/">下一页 <span
aria-hidden="true">&rarr;</span></a></li>
{% endif %}
</ul>
</nav>
</div>
{% endblock %} {% endblock %}

View File

@@ -0,0 +1,17 @@
# coding=utf-8
import datetime
from account.models import User
def get_username(user_id):
try:
return User.objects.get(id=user_id).username
except User.DoesNotExist:
return ""
from django import template
register = template.Library()
register.filter("get_username", get_username)