From 9b5049b89affd195c4c83a5ecf34282464985856 Mon Sep 17 00:00:00 2001 From: virusdefender <1670873886@qq.com> Date: Fri, 11 Sep 2015 20:33:37 +0800 Subject: [PATCH] =?UTF-8?q?=E6=88=91=E7=9A=84=E6=8F=90=E4=BA=A4=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E5=A2=9E=E5=8A=A0=E9=A2=98=E7=9B=AE=E5=90=8D=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- submission/views.py | 10 ++++ .../src/oj/problem/my_submissions_list.html | 52 ------------------- .../oj/submission/my_submissions_list.html | 2 +- 3 files changed, 11 insertions(+), 53 deletions(-) delete mode 100644 template/src/oj/problem/my_submissions_list.html diff --git a/submission/views.py b/submission/views.py index 984cb724..19f3c292 100644 --- a/submission/views.py +++ b/submission/views.py @@ -165,6 +165,16 @@ def my_submission_list_page(request, page=1): if result: submissions = submissions.filter(result=int(result)) filter = {"name": "result", "content": result} + + # 为 submission 查询题目 因为提交页面经常会有重复的题目,缓存一下查询结果 + cache_result = {} + for item in submissions: + problem_id = item["problem_id"] + if problem_id not in cache_result: + problem = Problem.objects.get(id=problem_id) + cache_result[problem_id] = problem.title + item["title"] = cache_result[problem_id] + paginator = Paginator(submissions, 20) try: current_page = paginator.page(int(page)) diff --git a/template/src/oj/problem/my_submissions_list.html b/template/src/oj/problem/my_submissions_list.html deleted file mode 100644 index 3bf7ac5f..00000000 --- a/template/src/oj/problem/my_submissions_list.html +++ /dev/null @@ -1,52 +0,0 @@ -{% extends 'oj_base.html' %} - -{% block body %} - - {% load submission %} -
- - {% include "oj/problem/_problem_header.html" %} - {% if submissions %} - - - - - - - - - - - - {% for item in submissions %} - - - - - - - - {% endfor %} - - -
#提交时间语言运行时间结果
{{ forloop.counter }}{{ item.create_time }} - {{ item.language|translate_language }} - - {% if item.accepted_answer_time %} - {{ item.accepted_answer_time }}ms - {% else %} - -- - {% endif %} - - {{ item.result|translate_result }} -
- {% else %} -

你还没有提交该题目

- {% endif %} -
-{% endblock %} \ No newline at end of file diff --git a/template/src/oj/submission/my_submissions_list.html b/template/src/oj/submission/my_submissions_list.html index 08cf17d2..6df28eb0 100644 --- a/template/src/oj/submission/my_submissions_list.html +++ b/template/src/oj/submission/my_submissions_list.html @@ -52,7 +52,7 @@ {{ forloop.counter |add:start_id }} - {{ item.problem_id }} + {{ item.title }} {{ item.create_time }}