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

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

@@ -3,6 +3,7 @@
{% block body %} {% block body %}
{% load submission %} {% load submission %}
{% load user %}
<div class="container main"> <div class="container main">
<div class="contest-tab"> <div class="contest-tab">
<ul class="nav nav-tabs nav-tabs-google"> <ul class="nav nav-tabs nav-tabs-google">
@@ -25,6 +26,7 @@
<thead> <thead>
<tr class="" success> <tr class="" success>
<th>#</th> <th>#</th>
<td>用户</td>
<th>提交时间</th> <th>提交时间</th>
<th>结果</th> <th>结果</th>
<th>运行时间</th> <th>运行时间</th>
@@ -42,6 +44,8 @@
<th scope="row">{{ forloop.counter |add:start_id }}</th> <th scope="row">{{ forloop.counter |add:start_id }}</th>
{% endifequal %} {% endifequal %}
<td>{{ item.user_id|get_username }}</td>
<td>{{ item.create_time }}</td> <td>{{ item.create_time }}</td>
<td>{{ item.result|translate_result }}</td> <td>{{ item.result|translate_result }}</td>
<td> <td>

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)