更新我的提交列表页面

This commit is contained in:
virusdefender 2015-08-13 21:02:17 +08:00
parent 58f9014688
commit 94282f3ed8
8 changed files with 101 additions and 60 deletions

View File

@ -51,6 +51,7 @@ INSTALLED_APPS = (
'group',
'problem',
'admin',
'submission',
'rest_framework',
'rest_framework_swagger',

View File

@ -42,7 +42,7 @@ urlpatterns = [
name="add_contest_page"),
url(r'^problems/$', TemplateView.as_view(template_name="oj/problem/problem_list.html"),
name="problem_list_page"),
url(r'^admin/template/(?P<template_dir>\w+)/(?P<template_name>\w+).html', AdminTemplateView.as_view(),
url(r'^admin/template/(?P<template_dir>\w+)/(?P<template_name>\w+).html$', AdminTemplateView.as_view(),
name="admin_template"),
url(r'^api/admin/group/$', GroupAdminAPIView.as_view(), name="group_admin_api"),
url(r'^api/admin/group_member/$', GroupMemberAdminAPIView.as_view(), name="group_member_admin_api"),
@ -50,9 +50,9 @@ urlpatterns = [
url(r'^api/admin/problem/$', ProblemAdminAPIView.as_view(), name="problem_admin_api"),
url(r'^api/admin/test_case_upload/$', TestCaseUploadAPIView.as_view(), name="test_case_upload_api"),
url(r'^api/admin/tag/$', ProblemTagAdminAPIView.as_view(), name="problem_tag_admin_api"),
url(r'^problem/(?P<problem_id>\d+)/my_solutions/', "submission.views.problem_my_submissions_list_page",
url(r'^problem/(?P<problem_id>\d+)/my_solutions/$', "submission.views.problem_my_submissions_list_page",
name="problem_my_submissions_page"),
url(r'^my_solution/(?P<solution_id>\d+)/$', "submission.views.my_submission", name="my_submission_page"),
url(r'^my_solution/(?P<solution_id>\w+)/$', "submission.views.my_submission", name="my_submission_page"),
url(r'^api/admin/join_group_request/$', JoinGroupRequestAdminAPIView.as_view(),
name="join_group_request_admin_api"),

View File

@ -0,0 +1 @@
# coding=utf-8

View File

@ -0,0 +1,28 @@
# coding=utf-8
def translate_result(value):
print value
results = {
0: "Accepted",
1: "Runtime Error",
2: "Time Limit Exceeded",
3: "Memory Limit Exceeded",
4: "Compile Error",
5: "Format Error",
6: "Wrong Answer",
7: "System Error",
8: "Waiting"
}
return results[value]
def translate_id(submission_item):
print submission_item
return submission_item["_id"]
from django import template
register = template.Library()
register.filter("translate_result", translate_result)
register.filter("translate_id", translate_id)

View File

@ -69,9 +69,9 @@ class SubmissionnAPIView(APIView):
def problem_my_submissions_list_page(request, problem_id):
collection = _create_mondodb_connection()
submissions = collection.find({"problem_id": int(problem_id), "user_id": request.user.id},
projection=["result", "accepted_answer_info", "create_time"],
projection=["result", "accepted_answer_info", "create_time", "language"],
sort=[["create_time", -pymongo.ASCENDING]])
return render(request, "oj/problem/my_solutions_list.html", {"submissions": submissions})
return render(request, "oj/problem/my_submissions_list.html", {"submissions": submissions})
def my_submission(request, solution_id):

View File

@ -1,53 +0,0 @@
{% extends 'oj_base.html' %}
{% block body %}
<div class="container main">
<ul class="nav nav-tabs nav-tabs-google">
<li role="presentation">
<a href="/problem/1/">题目</a></li>
<li role="presentation" class="active"><a href="my_solutions_list.html">我的提交</a></li>
</ul>
<h2 class="text-center">Battle Over Cities - Hard Version</h2>
<p class="text-muted text-center">cpu: 1000ms 内存: 256M</p>
<table class="table table-bordered">
<thead>
<tr class=""success>
<th>#</th>
<th>提交时间</th>
<th>结果</th>
<th>运行时间</th>
<th>运行内存</th>
<th>语言</th>
</tr>
</thead>
<tbody>
<tr class="warning">
<th scope="row">1</th>
<td>1</td>
<td>Error Format</td>
<td>3</td>
<td>3</td>
<td>3</td>
</tr>
<tr class="danger">
<th scope="row">2</th>
<td>Wrong</td>
<td>Wrong Answer</td>
<td>@fat</td>
<td>3</td>
<td>3</td>
</tr>
<tr class="success">
<th scope="row">3</th>
<td>Larry</td>
<td>Accepted</td>
<td>@twitter</td>
<td>3</td>
<td>3</td>
</tr>
</tbody>
</table>
</div>
{% endblock %}

View File

@ -0,0 +1,64 @@
{% extends 'oj_base.html' %}
{% block body %}
{% load submission %}
<div class="container main">
<ul class="nav nav-tabs nav-tabs-google">
<li role="presentation">
<a href="/problem/1/">题目</a></li>
<li role="presentation" class="active"><a href="my_solutions_list.html">我的提交</a></li>
</ul>
<h2 class="text-center">Battle Over Cities - Hard Version</h2>
<p class="text-muted text-center">cpu: 1000ms 内存: 256M</p>
<table class="table table-bordered">
<thead>
<tr class="" success>
<th>#</th>
<th>提交时间</th>
<th>结果</th>
<th>运行时间</th>
<th>语言</th>
</tr>
</thead>
<tbody>
{% for item in submissions %}
{% ifequal item.result 0 %}
<tr class="success">
{% else %}
{% ifequal item.result 8 %}
<tr class="info">
{% else %}
<tr class="danger">
{% endifequal %}
{% endifequal %}
<th scope="row"><a href="/my_solution/{{ item|translate_id }}/">{{ forloop.counter }}</a></th>
<td>{{ item.create_time }}</td>
<td>{{ item.result|translate_result }}</td>
<td>
{% if item.accepted_answer_info.time %}
{{ item.accepted_answer_info.time }}ms
{% else %}
--
{% endif %}
</td>
<td>
{% ifequal item.language 1 %}
C
{% else %}
{% ifequal item.language 2 %}
C++
{% else %}
Java
{% endifequal %}
{% endifequal %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endblock %}

View File

@ -67,10 +67,10 @@
<div>
<label class="radio-inline">
<input type="radio" name="language" value="1" checked> c (gcc 4.8)
<input type="radio" name="language" value="1" checked> C (gcc 4.8)
</label>
<label class="radio-inline">
<input type="radio" name="language" value="2"> c++ (g++ 4.3)
<input type="radio" name="language" value="2"> C++ (g++ 4.3)
</label>
<label class="radio-inline">
<input type="radio" name="language" value="3"> Java (jre 1.7)