From ae6566b92f93351921124e3d7a3c467070e0e4a2 Mon Sep 17 00:00:00 2001
From: virusdefender <1670873886@qq.com>
Date: Fri, 21 Aug 2015 17:58:22 +0800
Subject: [PATCH 3/5] =?UTF-8?q?=E5=AE=8C=E6=88=90=E9=A6=96=E9=A1=B5?=
=?UTF-8?q?=E7=9A=84=E5=85=AC=E5=91=8A=E5=88=97=E8=A1=A8=EF=BC=8C=E6=A0=87?=
=?UTF-8?q?=E7=AD=BE=E5=88=97=E8=A1=A8=E7=AD=89=E5=8A=9F=E8=83=BD=E3=80=82?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
problem/views.py | 11 ++++++--
static/src/css/oj.css | 4 +++
submission/models.py | 4 +--
template/oj/problem/problem_list.html | 36 +++++++++++----------------
4 files changed, 29 insertions(+), 26 deletions(-)
diff --git a/problem/views.py b/problem/views.py
index 4a6e2c6..26a3a5b 100644
--- a/problem/views.py
+++ b/problem/views.py
@@ -6,13 +6,14 @@ import hashlib
import json
from django.shortcuts import render
-from django.db.models import Q
+from django.db.models import Q, Count
from django.core.paginator import Paginator
from rest_framework.views import APIView
from django.conf import settings
+from announcement.models import Announcement
from utils.shortcuts import (serializer_invalid_response, error_response,
success_response, paginate, rand_str, error_page)
from .serizalizers import (CreateProblemSerializer, EditProblemSerializer, ProblemSerializer,
@@ -251,7 +252,13 @@ def problem_list_page(request, page=1):
except Exception:
pass
+ # 右侧的公告列表
+ announcements = Announcement.objects.filter(is_global=True, visible=True).order_by("-create_time")
+ # 右侧标签列表 按照关联的题目的数量排序 排除题目数量为0的
+ tags = ProblemTag.objects.annotate(problem_number=Count("problem")).filter(problem_number__gt=0).order_by("-problem_number")
+
return render(request, "oj/problem/problem_list.html",
{"problems": current_page, "page": int(page),
"previous_page": previous_page, "next_page": next_page,
- "keyword": keyword, "tag": tag_text})
+ "keyword": keyword, "tag": tag_text,
+ "announcements": announcements, "tags": tags})
diff --git a/static/src/css/oj.css b/static/src/css/oj.css
index cc6ac62..e6bd835 100644
--- a/static/src/css/oj.css
+++ b/static/src/css/oj.css
@@ -67,4 +67,8 @@ li.list-group-item {
.panel>.list-group{
padding: 0 0;
+}
+
+.ac-flag{
+ color: green;
}
\ No newline at end of file
diff --git a/submission/models.py b/submission/models.py
index 3442183..2cde917 100644
--- a/submission/models.py
+++ b/submission/models.py
@@ -6,12 +6,12 @@ from judge.judger.result import result
class Submission(models.Model):
id = models.CharField(max_length=32, default=rand_str, primary_key=True, db_index=True)
- user_id = models.IntegerField()
+ user_id = models.IntegerField(db_index=True)
create_time = models.DateTimeField(auto_now_add=True)
result = models.IntegerField(default=result["waiting"])
language = models.IntegerField()
code = models.TextField()
- problem_id = models.IntegerField()
+ problem_id = models.IntegerField(db_index=True)
# 这个字段可能存储很多数据 比如编译错误、系统错误的时候,存储错误原因字符串
# 正常运行的时候存储 lrun 的判题结果,比如cpu时间内存之类的
info = models.TextField(blank=True, null=True)
diff --git a/template/oj/problem/problem_list.html b/template/oj/problem/problem_list.html
index d851012..073cfe7 100644
--- a/template/oj/problem/problem_list.html
+++ b/template/oj/problem/problem_list.html
@@ -18,15 +18,17 @@
+ |
# |
题目 |
- 难度 |
- 通过率 |
+ 难度 |
+ 通过率 |
{% for item in problems %}
+ |
{{ item.id }} |
{{ item.title }} |
{{ item.difficulty }} |
@@ -59,7 +61,11 @@
公告
- Panel content
+
+ {% for item in announcements %}
+ {{ forloop.counter }}.
{{ item.title }}
+ {% endfor %}
+
@@ -69,26 +75,12 @@
- -
- 14
- Cras justo odio
-
- -
- 14
- Cras justo odio
-
- -
- 14
- Cras justo odio
-
- -
- 14
- Cras justo odio
-
- -
- 14
- Cras justo odio
+ {% for item in tags %}
+
-
+ {{ item.problem_number }}
+ {{ item.name }}
+ {% endfor %}
From d36c2b17b7a488796a90c1eb70277a9643e991a3 Mon Sep 17 00:00:00 2001
From: virusdefender <1670873886@qq.com>
Date: Fri, 21 Aug 2015 17:59:00 +0800
Subject: [PATCH 4/5] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dsubmission=20=E5=88=97?=
=?UTF-8?q?=E8=A1=A8=E5=B1=95=E7=A4=BA=E9=9D=9E=E5=B8=B8=E6=85=A2=E7=9A=84?=
=?UTF-8?q?=E9=97=AE=E9=A2=98=EF=BC=8C=E4=B8=8D=E8=A6=81=E5=8E=BB=E7=A2=B0?=
=?UTF-8?q?=E9=82=A3=E4=BA=9B=E5=A4=A7=E5=AD=97=E6=AE=B5?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../migrations/0003_auto_20150821_1654.py | 24 +++++++++++++++++++
submission/views.py | 2 +-
2 files changed, 25 insertions(+), 1 deletion(-)
create mode 100644 submission/migrations/0003_auto_20150821_1654.py
diff --git a/submission/migrations/0003_auto_20150821_1654.py b/submission/migrations/0003_auto_20150821_1654.py
new file mode 100644
index 0000000..22ab59d
--- /dev/null
+++ b/submission/migrations/0003_auto_20150821_1654.py
@@ -0,0 +1,24 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import models, migrations
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('submission', '0002_submission_is_counted'),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name='submission',
+ name='problem_id',
+ field=models.IntegerField(db_index=True),
+ ),
+ migrations.AlterField(
+ model_name='submission',
+ name='user_id',
+ field=models.IntegerField(db_index=True),
+ ),
+ ]
diff --git a/submission/views.py b/submission/views.py
index 1524643..f824841 100644
--- a/submission/views.py
+++ b/submission/views.py
@@ -84,7 +84,7 @@ def problem_my_submissions_list_page(request, problem_id):
problem = Problem.objects.get(id=problem_id, visible=True)
except Problem.DoesNotExist:
return error_page(request, u"问题不存在")
- submissions = Submission.objects.filter(user_id=request.user.id, problem_id=problem.id).order_by("-create_time")
+ submissions = Submission.objects.filter(user_id=request.user.id, problem_id=problem.id).values("id", "result", "create_time", "accepted_answer_time", "language")
return render(request, "oj/problem/my_submissions_list.html",
{"submissions": submissions, "problem": problem})
From 2a55da23ecb106f7ae95ce12cda2d22924077cf7 Mon Sep 17 00:00:00 2001
From: virusdefender <1670873886@qq.com>
Date: Fri, 21 Aug 2015 18:01:18 +0800
Subject: [PATCH 5/5] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=88=91=E7=9A=84?=
=?UTF-8?q?=E6=8F=90=E4=BA=A4=E5=88=97=E8=A1=A8=E6=8E=92=E5=BA=8F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
submission/views.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/submission/views.py b/submission/views.py
index f824841..26e8d3a 100644
--- a/submission/views.py
+++ b/submission/views.py
@@ -84,7 +84,8 @@ def problem_my_submissions_list_page(request, problem_id):
problem = Problem.objects.get(id=problem_id, visible=True)
except Problem.DoesNotExist:
return error_page(request, u"问题不存在")
- submissions = Submission.objects.filter(user_id=request.user.id, problem_id=problem.id).values("id", "result", "create_time", "accepted_answer_time", "language")
+ submissions = Submission.objects.filter(user_id=request.user.id, problem_id=problem.id).order_by("-create_time").\
+ values("id", "result", "create_time", "accepted_answer_time", "language")
return render(request, "oj/problem/my_submissions_list.html",
{"submissions": submissions, "problem": problem})