From 588a5e1a7109f41d6bd7907ff9d6910a973e584e Mon Sep 17 00:00:00 2001
From: hohoTT <609029365@qq.com>
Date: Tue, 8 Sep 2015 21:24:57 +0800
Subject: [PATCH 1/3] =?UTF-8?q?=E6=AF=94=E8=B5=9B=E6=8F=8F=E8=BF=B0?=
=?UTF-8?q?=E5=B1=85=E4=B8=AD=EF=BC=8C=E6=B3=A8=E6=84=8F=EF=BC=9A=E5=90=8E?=
=?UTF-8?q?=E5=8F=B0=E5=86=99=E9=A2=98=E7=9B=AE=E6=8F=8F=E8=BF=B0=E7=9A=84?=
=?UTF-8?q?=E6=97=B6=E5=80=99=E6=97=A0=E9=9C=80=E7=A9=BA=E6=A0=BC=EF=BC=8C?=
=?UTF-8?q?=E6=8F=8F=E8=BF=B0=E4=BC=9A=E8=87=AA=E5=8A=A8=E5=B1=85=E4=B8=AD?=
=?UTF-8?q?=EF=BC=8C=E4=B8=8D=E7=84=B6=E6=8F=8F=E8=BF=B0=E4=BC=9A=E5=81=8F?=
=?UTF-8?q?=E7=A6=BB=E5=8E=9F=E6=9D=A5=E5=B1=85=E4=B8=AD=E7=9A=84=E6=96=B9?=
=?UTF-8?q?=E5=90=91=E3=80=82?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
【后台文本编辑器好像存在BUG】:编辑好描述后,再次编辑的时候,如果之前编辑中每行文字最前面有空格则无法删除。
---
template/src/oj/contest/_contest_header.html | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/template/src/oj/contest/_contest_header.html b/template/src/oj/contest/_contest_header.html
index 62892cea..bcf4cabe 100644
--- a/template/src/oj/contest/_contest_header.html
+++ b/template/src/oj/contest/_contest_header.html
@@ -33,6 +33,6 @@
- {{ contest.description|safe }}
+ {{ contest.description|safe }}
\ No newline at end of file
From 24758a358968019f80dd3c36be2a4b40ef535fc7 Mon Sep 17 00:00:00 2001
From: hohoTT <609029365@qq.com>
Date: Wed, 9 Sep 2015 19:39:42 +0800
Subject: [PATCH 2/3] =?UTF-8?q?contest=20type=20=E7=9A=84=E8=A1=A8?=
=?UTF-8?q?=E7=A4=BA=E7=B1=BB=E5=9E=8B=E4=BF=AE=E6=94=B9=E4=B8=BA=E5=B8=B8?=
=?UTF-8?q?=E9=87=8F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
0 即为是小组赛(GROUP_CONTEST),1 即为是无密码的公开赛(PUBLIC_CONTEST),2 即为是有密码的公开赛(PASSWORD_PUBLIC_CONTEST)
---
contest/models.py | 8 ++++-
contest/tests.py | 66 +++++++++++++++++++++----------------
contest/views.py | 20 ++++++-----
contest_submission/tests.py | 10 ++++--
submission/tests.py | 10 ++++--
5 files changed, 69 insertions(+), 45 deletions(-)
diff --git a/contest/models.py b/contest/models.py
index 338e3b18..cab1cc6a 100644
--- a/contest/models.py
+++ b/contest/models.py
@@ -7,6 +7,11 @@ from problem.models import AbstractProblem
from group.models import Group
+GROUP_CONTEST = 0
+PUBLIC_CONTEST = 1
+PASSWORD_PUBLIC_CONTEST = 2
+
+
class Contest(models.Model):
title = models.CharField(max_length=40, unique=True)
description = models.TextField()
@@ -19,7 +24,8 @@ class Contest(models.Model):
# 只能超级管理员创建公开赛,管理员只能创建小组内部的比赛
# 如果这一项不为空,即为有密码的公开赛,没有密码的可以为小组赛或者是公开赛(此时用比赛的类型来表示)
password = models.CharField(max_length=30, blank=True, null=True)
- # 比赛的类型: 0 即为是小组赛,1 即为是无密码的公开赛,2 即为是有密码的公开赛
+ # 比赛的类型: 0 即为是小组赛(GROUP_CONTEST),1 即为是无密码的公开赛(PUBLIC_CONTEST),
+ # 2 即为是有密码的公开赛(PASSWORD_PUBLIC_CONTEST)
contest_type = models.IntegerField()
# 开始时间
start_time = models.DateTimeField()
diff --git a/contest/tests.py b/contest/tests.py
index 626a3abb..990913d5 100644
--- a/contest/tests.py
+++ b/contest/tests.py
@@ -10,6 +10,7 @@ from account.models import User
from group.models import Group
from contest.models import Contest, ContestProblem
from .models import ContestSubmission
+from .models import GROUP_CONTEST, PUBLIC_CONTEST, PASSWORD_PUBLIC_CONTEST
from announcement.models import Announcement
from account.models import REGULAR_USER, ADMIN, SUPER_ADMIN
from decorators import check_user_contest_permission
@@ -32,15 +33,17 @@ class ContestAdminAPITest(APITestCase):
join_group_setting=0, visible=True,
admin=user2)
self.group2 = Group.objects.create(name="group2", description="des0",
- join_group_setting=0, visible=True,
- admin=user1)
+ join_group_setting=0, visible=True,
+ admin=user1)
self.global_contest = Contest.objects.create(title="titlex", description="descriptionx", mode=1,
- contest_type=2, show_rank=True, show_user_submission=True,
+ contest_type=PASSWORD_PUBLIC_CONTEST, show_rank=True,
+ show_user_submission=True,
start_time="2015-08-15T10:00:00.000Z",
end_time="2015-08-15T12:00:00.000Z",
password="aacc", created_by=User.objects.get(username="test1"))
self.group_contest = Contest.objects.create(title="titley", description="descriptiony", mode=1,
- contest_type=2, show_rank=True, show_user_submission=True,
+ contest_type=PASSWORD_PUBLIC_CONTEST, show_rank=True,
+ show_user_submission=True,
start_time="2015-08-15T10:00:00.000Z",
end_time="2015-08-15T12:00:00.000Z",
password="aacc", created_by=User.objects.get(username="test1"))
@@ -54,7 +57,7 @@ class ContestAdminAPITest(APITestCase):
def test_global_contest_does_not_has_privileges(self):
self.client.login(username="test2", password="testbb")
- data = {"title": "title0", "description": "description0", "mode": 1, "contest_type": 2,
+ data = {"title": "title0", "description": "description0", "mode": 1, "contest_type": PASSWORD_PUBLIC_CONTEST,
"show_rank": True, "show_user_submission": True, "start_time": "2015-08-15T10:00:00.000Z",
"end_time": "2015-08-15T12:00:00.000Z", "password": "aabb", "visible": True}
response = self.client.post(self.url, data=data)
@@ -62,7 +65,7 @@ class ContestAdminAPITest(APITestCase):
def test_global_contest_password_exists(self):
self.client.login(username="test1", password="testaa")
- data = {"title": "title0", "description": "description0", "mode": 1, "contest_type": 2,
+ data = {"title": "title0", "description": "description0", "mode": 1, "contest_type": PASSWORD_PUBLIC_CONTEST,
"show_rank": True, "show_user_submission": True, "start_time": "2015-08-15T10:00:00.000Z",
"end_time": "2015-08-15T12:00:00.000Z", "visible": True}
response = self.client.post(self.url, data=data)
@@ -70,7 +73,7 @@ class ContestAdminAPITest(APITestCase):
def test_group_contest_group_at_least_one(self):
self.client.login(username="test1", password="testaa")
- data = {"title": "title0", "description": "description0", "mode": 1, "contest_type": 0,
+ data = {"title": "title0", "description": "description0", "mode": 1, "contest_type": GROUP_CONTEST,
"show_rank": True, "show_user_submission": True, "start_time": "2015-08-15T10:00:00.000Z",
"end_time": "2015-08-15T12:00:00.000Z", "visible": True}
response = self.client.post(self.url, data=data)
@@ -78,7 +81,7 @@ class ContestAdminAPITest(APITestCase):
def test_global_contest_successfully(self):
self.client.login(username="test1", password="testaa")
- data = {"title": "title1", "description": "description1", "mode": 1, "contest_type": 2,
+ data = {"title": "title1", "description": "description1", "mode": 1, "contest_type": PASSWORD_PUBLIC_CONTEST,
"show_rank": True, "show_user_submission": True, "start_time": "2015-08-15T10:00:00.000Z",
"end_time": "2015-08-15T12:00:00.000Z", "password": "aabb", "visible": True}
response = self.client.post(self.url, data=data)
@@ -86,7 +89,7 @@ class ContestAdminAPITest(APITestCase):
def test_group_contest_super_admin_successfully(self):
self.client.login(username="test1", password="testaa")
- data = {"title": "title3", "description": "description3", "mode": 1, "contest_type": 0,
+ data = {"title": "title3", "description": "description3", "mode": 1, "contest_type": GROUP_CONTEST,
"show_rank": True, "show_user_submission": True, "start_time": "2015-08-15T10:00:00.000Z",
"end_time": "2015-08-15T12:00:00.000Z", "groups": [self.group.id], "visible": True}
response = self.client.post(self.url, data=data)
@@ -94,7 +97,7 @@ class ContestAdminAPITest(APITestCase):
def test_group_contest_admin_successfully(self):
self.client.login(username="test2", password="testbb")
- data = {"title": "title6", "description": "description6", "mode": 2, "contest_type": 0,
+ data = {"title": "title6", "description": "description6", "mode": 2, "contest_type": GROUP_CONTEST,
"show_rank": True, "show_user_submission": True, "start_time": "2015-08-15T10:00:00.000Z",
"end_time": "2015-08-15T12:00:00.000Z", "groups": [self.group.id], "visible": True}
response = self.client.post(self.url, data=data)
@@ -102,7 +105,7 @@ class ContestAdminAPITest(APITestCase):
def test_time_error(self):
self.client.login(username="test1", password="testaa")
- data = {"title": "title2", "description": "description2", "mode": 1, "contest_type": 2,
+ data = {"title": "title2", "description": "description2", "mode": 1, "contest_type": PASSWORD_PUBLIC_CONTEST,
"show_rank": True, "show_user_submission": True, "start_time": "2015-08-15T12:00:00.000Z",
"end_time": "2015-08-15T10:00:00.000Z", "password": "aabb", "visible": True}
response = self.client.post(self.url, data=data)
@@ -110,7 +113,7 @@ class ContestAdminAPITest(APITestCase):
def test_contest_has_exists(self):
self.client.login(username="test1", password="testaa")
- data = {"title": "titlex", "description": "descriptionx", "mode": 1, "contest_type": 2,
+ data = {"title": "titlex", "description": "descriptionx", "mode": 1, "contest_type": PASSWORD_PUBLIC_CONTEST,
"show_rank": True, "show_user_submission": True, "start_time": "2015-08-15T10:00:00.000Z",
"end_time": "2015-08-15T12:00:00.000Z", "password": "aabb", "visible": True}
response = self.client.post(self.url, data=data)
@@ -126,7 +129,7 @@ class ContestAdminAPITest(APITestCase):
def test_contest_does_not_exist(self):
self.client.login(username="test1", password="testaa")
data = {"id": self.global_contest.id + 10, "title": "title2", "description": "description2", "mode": 1,
- "contest_type": 2, "show_rank": True, "show_user_submission": True,
+ "contest_type": PASSWORD_PUBLIC_CONTEST, "show_rank": True, "show_user_submission": True,
"start_time": "2015-08-15T10:00:00.000Z", "end_time": "2015-08-15T12:00:00.000Z", "password": "aabb",
"visible": True}
response = self.client.put(self.url, data=data)
@@ -135,7 +138,7 @@ class ContestAdminAPITest(APITestCase):
def test_edit_global_contest_successfully(self):
self.client.login(username="test1", password="testaa")
data = {"id": self.global_contest.id, "title": "titlez", "description": "descriptionz", "mode": 1,
- "contest_type": 2, "show_rank": True, "show_user_submission": True,
+ "contest_type": PASSWORD_PUBLIC_CONTEST, "show_rank": True, "show_user_submission": True,
"start_time": "2015-08-15T10:00:00.000Z", "end_time": "2015-08-15T13:00:00.000Z", "password": "aabb",
"visible": True}
response = self.client.put(self.url, data=data)
@@ -146,7 +149,7 @@ class ContestAdminAPITest(APITestCase):
def test_edit_group_contest_successfully(self):
self.client.login(username="test1", password="testaa")
data = {"id": self.group_contest.id, "title": "titleyyy", "description": "descriptionyyyy", "mode": 1,
- "contest_type": 0, "show_rank": True, "show_user_submission": True,
+ "contest_type": GROUP_CONTEST, "show_rank": True, "show_user_submission": True,
"start_time": "2015-08-15T10:00:00.000Z", "end_time": "2015-08-15T13:00:00.000Z",
"groups": [self.group.id], "visible": False}
response = self.client.put(self.url, data=data)
@@ -158,7 +161,7 @@ class ContestAdminAPITest(APITestCase):
def test_edit_group_contest_unsuccessfully(self):
self.client.login(username="test2", password="testbb")
data = {"id": self.group_contest.id, "title": "titleyyy", "description": "descriptionyyyy", "mode": 1,
- "contest_type": 0, "show_rank": True, "show_user_submission": True,
+ "contest_type": GROUP_CONTEST, "show_rank": True, "show_user_submission": True,
"start_time": "2015-08-15T10:00:00.000Z", "end_time": "2015-08-15T13:00:00.000Z",
"groups": [self.group.id], "visible": False}
response = self.client.put(self.url, data=data)
@@ -167,7 +170,7 @@ class ContestAdminAPITest(APITestCase):
def test_edit_group_at_least_one(self):
self.client.login(username="test1", password="testaa")
data = {"id": self.group_contest.id, "title": "titleyyy", "description": "descriptionyyyy", "mode": 1,
- "contest_type": 0, "show_rank": True, "show_user_submission": True,
+ "contest_type": GROUP_CONTEST, "show_rank": True, "show_user_submission": True,
"start_time": "2015-08-15T10:00:00.000Z", "end_time": "2015-08-15T13:00:00.000Z", "visible": True}
response = self.client.put(self.url, data=data)
self.assertEqual(response.data, {"code": 1, "data": u"请至少选择一个小组"})
@@ -175,7 +178,7 @@ class ContestAdminAPITest(APITestCase):
def test_edit_contest_has_exists(self):
self.client.login(username="test1", password="testaa")
data = {"id": self.global_contest.id, "title": "titley", "description": "descriptiony", "mode": 1,
- "contest_type": 2, "show_rank": True, "show_user_submission": True,
+ "contest_type": PASSWORD_PUBLIC_CONTEST, "show_rank": True, "show_user_submission": True,
"start_time": "2015-08-15T10:00:00.000Z", "end_time": "2015-08-15T12:00:00.000Z", "password": "aabb",
"visible": True}
response = self.client.put(self.url, data=data)
@@ -184,7 +187,7 @@ class ContestAdminAPITest(APITestCase):
def test_edit_global_contest_does_not_has_privileges(self):
self.client.login(username="test2", password="testbb")
data = {"id": self.global_contest.id, "title": "titlexxxxxxxxx", "description": "descriptionxxxxxx", "mode": 1,
- "contest_type": 2, "show_rank": True, "show_user_submission": True,
+ "contest_type": PASSWORD_PUBLIC_CONTEST, "show_rank": True, "show_user_submission": True,
"start_time": "2015-08-15T10:00:00.000Z", "end_time": "2015-08-15T12:00:00.000Z", "password": "aabb",
"visible": True}
response = self.client.put(self.url, data=data)
@@ -193,8 +196,7 @@ class ContestAdminAPITest(APITestCase):
def test_edit_global_contest_password_exists(self):
self.client.login(username="test1", password="testaa")
data = {"id": self.global_contest.id, "title": "title0", "description": "description0", "mode": 1,
- "contest_type": 2,
- "show_rank": True, "show_user_submission": True, "start_time": "2015-08-15T10:00:00.000Z",
+ "contest_type": PASSWORD_PUBLIC_CONTEST, "show_rank": True, "show_user_submission": True, "start_time": "2015-08-15T10:00:00.000Z",
"end_time": "2015-08-15T12:00:00.000Z", "visible": True}
response = self.client.put(self.url, data=data)
self.assertEqual(response.data, {"code": 1, "data": u"此比赛为有密码的公开赛,密码不可为空"})
@@ -202,7 +204,7 @@ class ContestAdminAPITest(APITestCase):
def test_edit_time_error(self):
self.client.login(username="test1", password="testaa")
data = {"id": self.global_contest.id, "title": "titleaaaa", "description": "descriptionaaaaa", "mode": 1,
- "contest_type": 2, "show_rank": True, "show_user_submission": True,
+ "contest_type": PASSWORD_PUBLIC_CONTEST, "show_rank": True, "show_user_submission": True,
"start_time": "2015-08-15T12:00:00.000Z", "end_time": "2015-08-15T10:00:00.000Z", "password": "aabb",
"visible": True}
response = self.client.put(self.url, data=data)
@@ -245,7 +247,8 @@ class ContestProblemAdminAPItEST(APITestCase):
self.user3.save()
self.client.login(username="test1", password="testaa")
self.global_contest = Contest.objects.create(title="titlex", description="descriptionx", mode=1,
- contest_type=2, show_rank=True, show_user_submission=True,
+ contest_type=PASSWORD_PUBLIC_CONTEST, show_rank=True,
+ show_user_submission=True,
start_time="2015-08-15T10:00:00.000Z",
end_time="2015-08-15T12:00:00.000Z",
password="aacc", created_by=User.objects.get(username="test1"))
@@ -373,7 +376,7 @@ class ContestProblemAdminAPItEST(APITestCase):
def test_query_contest_problem_exists_by_contest_id(self):
self.client.login(username="test3", password="testaa")
- response = self.client.get(self.url + "?contest_id="+ str(self.global_contest.id))
+ response = self.client.get(self.url + "?contest_id=" + str(self.global_contest.id))
self.assertEqual(response.data["code"], 0)
self.assertEqual(len(response.data["data"]), 0)
@@ -414,7 +417,8 @@ class ContestPasswordVerifyAPITest(APITestCase):
self.user2.save()
self.client.login(username="test1", password="testaa")
self.global_contest = Contest.objects.create(title="titlex", description="descriptionx", mode=1,
- contest_type=2, show_rank=True, show_user_submission=True,
+ contest_type=PASSWORD_PUBLIC_CONTEST, show_rank=True,
+ show_user_submission=True,
start_time="2015-08-15T10:00:00.000Z",
end_time="2015-08-15T12:00:00.000Z",
password="aacc", created_by=User.objects.get(username="test1"))
@@ -453,7 +457,8 @@ class ContestPageTest(TestCase):
self.user1.save()
self.client.login(username="test1", password="testaa")
self.global_contest = Contest.objects.create(title="titlex", description="descriptionx", mode=1,
- contest_type=2, show_rank=True, show_user_submission=True,
+ contest_type=PASSWORD_PUBLIC_CONTEST, show_rank=True,
+ show_user_submission=True,
start_time="2015-08-15T10:00:00.000Z",
end_time="2015-08-15T12:00:00.000Z",
password="aacc", created_by=User.objects.get(username="test1"))
@@ -476,7 +481,8 @@ class ContestProblemPageTest(TestCase):
self.user1.save()
self.client.login(username="test1", password="testaa")
self.global_contest = Contest.objects.create(title="titlex", description="descriptionx", mode=1,
- contest_type=2, show_rank=True, show_user_submission=True,
+ contest_type=PASSWORD_PUBLIC_CONTEST, show_rank=True,
+ show_user_submission=True,
start_time="2015-08-15T10:00:00.000Z",
end_time="2015-08-15T12:00:00.000Z",
password="aacc", created_by=User.objects.get(username="test1"))
@@ -519,7 +525,8 @@ class ContestProblemListPageTest(TestCase):
self.user1.save()
self.client.login(username="test1", password="testaa")
self.global_contest = Contest.objects.create(title="titlex", description="descriptionx", mode=1,
- contest_type=2, show_rank=True, show_user_submission=True,
+ contest_type=PASSWORD_PUBLIC_CONTEST, show_rank=True,
+ show_user_submission=True,
start_time="2015-08-15T10:00:00.000Z",
end_time="2015-08-15T12:00:00.000Z",
password="aacc", created_by=User.objects.get(username="test1"))
@@ -555,7 +562,8 @@ class ContestListPageTest(TestCase):
self.url = reverse('contest_list_page')
self.client.login(username="test1", password="testaa")
self.global_contest = Contest.objects.create(title="titlex", description="descriptionx", mode=1,
- contest_type=2, show_rank=True, show_user_submission=True,
+ contest_type=PASSWORD_PUBLIC_CONTEST, show_rank=True,
+ show_user_submission=True,
start_time="2015-08-15T10:00:00.000Z",
end_time="2015-08-15T12:00:00.000Z",
password="aacc", created_by=User.objects.get(username="test1"))
diff --git a/contest/views.py b/contest/views.py
index e68b81f5..30e94084 100644
--- a/contest/views.py
+++ b/contest/views.py
@@ -18,6 +18,7 @@ from group.models import Group
from announcement.models import Announcement
from .models import Contest, ContestProblem, ContestSubmission
+from .models import GROUP_CONTEST, PUBLIC_CONTEST, PASSWORD_PUBLIC_CONTEST
from .decorators import check_user_contest_permission
from .serializers import (CreateContestSerializer, ContestSerializer, EditContestSerializer,
CreateContestProblemSerializer, ContestProblemSerializer,
@@ -37,17 +38,18 @@ class ContestAdminAPIView(APIView):
if serializer.is_valid():
data = serializer.data
groups = []
- # 首先判断比赛的类型: 0 即为是小组赛,1 即为是无密码的公开赛,2 即为是有密码的公开赛
+ # 首先判断比赛的类型: 0 即为是小组赛(GROUP_CONTEST),1 即为是无密码的公开赛(PUBLIC_CONTEST),
+ # 2 即为是有密码的公开赛(PASSWORD_PUBLIC_CONTEST)
# 此时为有密码的公开赛,并且此时只能超级管理员才有权限此创建比赛
- if data["contest_type"] in [1, 2]:
+ if data["contest_type"] in [PUBLIC_CONTEST, PASSWORD_PUBLIC_CONTEST]:
if request.user.admin_type != SUPER_ADMIN:
return error_response(u"只有超级管理员才可创建公开赛")
- if data["contest_type"] == 2:
+ if data["contest_type"] == PASSWORD_PUBLIC_CONTEST:
if not data["password"]:
return error_response(u"此比赛为有密码的公开赛,密码不可为空")
# 没有密码的公开赛 没有密码的小组赛
- elif data["contest_type"] == 0:
+ elif data["contest_type"] == GROUP_CONTEST:
if request.user.admin_type == SUPER_ADMIN:
groups = Group.objects.filter(id__in=data["groups"])
else:
@@ -92,13 +94,13 @@ class ContestAdminAPIView(APIView):
return error_response(u"该比赛名称已经存在")
except Contest.DoesNotExist:
pass
- if data["contest_type"] in [1, 2]:
+ if data["contest_type"] in [PUBLIC_CONTEST, PASSWORD_PUBLIC_CONTEST]:
if request.user.admin_type != SUPER_ADMIN:
return error_response(u"只有超级管理员才可创建公开赛")
- if data["contest_type"] == 2:
+ if data["contest_type"] == PASSWORD_PUBLIC_CONTEST:
if not data["password"]:
return error_response(u"此比赛为有密码的公开赛,密码不可为空")
- elif data["contest_type"] == 0:
+ elif data["contest_type"] == GROUP_CONTEST:
if request.user.admin_type == SUPER_ADMIN:
groups = Group.objects.filter(id__in=data["groups"])
else:
@@ -256,7 +258,7 @@ class ContestPasswordVerifyAPIView(APIView):
if serializer.is_valid():
data = request.data
try:
- contest = Contest.objects.get(id=data["contest_id"], contest_type=2)
+ contest = Contest.objects.get(id=data["contest_id"], contest_type=PASSWORD_PUBLIC_CONTEST)
except Contest.DoesNotExist:
return error_response(u"比赛不存在")
@@ -355,7 +357,7 @@ def contest_list_page(request, page=1):
# 筛选我能参加的比赛
join = request.GET.get("join", None)
if join:
- contests = contests.filter(Q(contest_type__in=[1, 2]) | Q(groups__in=request.user.group_set.all())). \
+ contests = contests.filter(Q(contest_type__in=[PUBLIC_CONTEST, PASSWORD_PUBLIC_CONTEST]) | Q(groups__in=request.user.group_set.all())). \
filter(end_time__gt=datetime.datetime.now(), start_time__lt=datetime.datetime.now())
paginator = Paginator(contests, 20)
diff --git a/contest_submission/tests.py b/contest_submission/tests.py
index 975d11ca..a9576194 100644
--- a/contest_submission/tests.py
+++ b/contest_submission/tests.py
@@ -5,6 +5,7 @@ from django.core.urlresolvers import reverse
from account.models import User, REGULAR_USER, ADMIN, SUPER_ADMIN
from problem.models import Problem
from contest.models import Contest, ContestProblem
+from contest.models import GROUP_CONTEST, PUBLIC_CONTEST, PASSWORD_PUBLIC_CONTEST
from submission.models import Submission
from rest_framework.test import APITestCase, APIClient
@@ -20,7 +21,8 @@ class ContestSubmissionAPITest(APITestCase):
self.user2.set_password("testbb")
self.user2.save()
self.global_contest = Contest.objects.create(title="titlex", description="descriptionx", mode=1,
- contest_type=1, show_rank=True, show_user_submission=True,
+ contest_type=PUBLIC_CONTEST, show_rank=True,
+ show_user_submission=True,
start_time="2015-08-15T10:00:00.000Z",
end_time="2015-08-30T12:00:00.000Z",
created_by=User.objects.get(username="test1"))
@@ -70,7 +72,8 @@ class ContestProblemMySubmissionListTest(TestCase):
self.user2.set_password("testbb")
self.user2.save()
self.global_contest = Contest.objects.create(title="titlex", description="descriptionx", mode=1,
- contest_type=1, show_rank=True, show_user_submission=True,
+ contest_type=PUBLIC_CONTEST, show_rank=True,
+ show_user_submission=True,
start_time="2015-08-15T10:00:00.000Z",
end_time="2015-08-30T12:00:00.000Z",
created_by=User.objects.get(username="test1"))
@@ -104,7 +107,8 @@ class SubmissionAPITest(APITestCase):
self.userS.set_password("testbb")
self.userS.save()
self.global_contest = Contest.objects.create(title="titlex", description="descriptionx", mode=1,
- contest_type=2, show_rank=True, show_user_submission=True,
+ contest_type=PASSWORD_PUBLIC_CONTEST, show_rank=True,
+ show_user_submission=True,
start_time="2015-08-15T10:00:00.000Z",
end_time="2015-08-15T12:00:00.000Z",
password="aacc", created_by=self.userS
diff --git a/submission/tests.py b/submission/tests.py
index ad3b85a8..96d06f07 100644
--- a/submission/tests.py
+++ b/submission/tests.py
@@ -5,6 +5,7 @@ from django.core.urlresolvers import reverse
from account.models import User, REGULAR_USER, ADMIN, SUPER_ADMIN
from problem.models import Problem
from contest.models import Contest
+from contest.models import GROUP_CONTEST, PUBLIC_CONTEST, PASSWORD_PUBLIC_CONTEST
from submission.models import Submission
from rest_framework.test import APITestCase, APIClient
@@ -82,7 +83,8 @@ class SubmissionAPITest(APITestCase):
hint="hint1",
created_by=User.objects.get(username="test2"))
self.global_contest = Contest.objects.create(title="titlex", description="descriptionx", mode=1,
- contest_type=2, show_rank=True, show_user_submission=True,
+ contest_type=PASSWORD_PUBLIC_CONTEST, show_rank=True,
+ show_user_submission=True,
start_time="2015-08-15T10:00:00.000Z",
end_time="2015-08-15T12:00:00.000Z",
password="aacc", created_by=User.objects.get(username="test2"))
@@ -151,7 +153,8 @@ class SubmissionAdminAPITest(APITestCase):
hint="hint1",
created_by=self.user)
self.global_contest = Contest.objects.create(title="titlex", description="descriptionx", mode=1,
- contest_type=2, show_rank=True, show_user_submission=True,
+ contest_type=PASSWORD_PUBLIC_CONTEST, show_rank=True,
+ show_user_submission=True,
start_time="2015-08-15T10:00:00.000Z",
end_time="2015-08-15T12:00:00.000Z",
password="aacc", created_by=self.user)
@@ -190,7 +193,8 @@ class SubmissionPageTest(TestCase):
hint="hint1",
created_by=User.objects.get(username="test1"))
self.global_contest = Contest.objects.create(title="titlex", description="descriptionx", mode=1,
- contest_type=2, show_rank=True, show_user_submission=True,
+ contest_type=PASSWORD_PUBLIC_CONTEST, show_rank=True,
+ show_user_submission=True,
start_time="2015-08-15T10:00:00.000Z",
end_time="2015-08-15T12:00:00.000Z",
password="aacc", created_by=User.objects.get(username="test1"))
From 81e3381c6f8fdb9874b3f30a7ae3707e7f57e92a Mon Sep 17 00:00:00 2001
From: hohoTT <609029365@qq.com>
Date: Fri, 11 Sep 2015 16:27:03 +0800
Subject: [PATCH 3/3] =?UTF-8?q?=E6=94=B9=E6=89=93=E5=BC=80=E9=A2=98?=
=?UTF-8?q?=E7=9B=AE=E4=B8=BA=E5=BD=93=E5=89=8D=E7=AA=97=E5=8F=A3=E6=89=93?=
=?UTF-8?q?=E5=BC=80=EF=BC=8C=E5=B9=B6=E4=B8=94=E5=8E=BB=E6=8E=89=E9=A2=98?=
=?UTF-8?q?=E7=9B=AE=E5=8D=95=E9=A1=B5=E4=B8=AD=E7=9A=84=E8=BF=94=E5=9B=9E?=
=?UTF-8?q?=E9=80=89=E9=A1=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
template/src/oj/contest/contest_problem.html | 3 ---
template/src/oj/contest/contest_problems_list.html | 4 ++--
template/src/oj/problem/problem.html | 3 ---
template/src/oj/problem/problem_list.html | 4 ++--
4 files changed, 4 insertions(+), 10 deletions(-)
diff --git a/template/src/oj/contest/contest_problem.html b/template/src/oj/contest/contest_problem.html
index 0dc4918b..6f691b61 100644
--- a/template/src/oj/contest/contest_problem.html
+++ b/template/src/oj/contest/contest_problem.html
@@ -8,9 +8,6 @@
我的提交
- 返回
-
{{ contest_problem.title }}
diff --git a/template/src/oj/contest/contest_problems_list.html b/template/src/oj/contest/contest_problems_list.html
index 5118d3e0..0d953b29 100644
--- a/template/src/oj/contest/contest_problems_list.html
+++ b/template/src/oj/contest/contest_problems_list.html
@@ -57,10 +57,10 @@
- {{ item.sort_index }}
+ {{ item.sort_index }}
|
- {{ item.title }}
+ {{ item.title }}
|
{{ item|accepted_radio }} |
diff --git a/template/src/oj/problem/problem.html b/template/src/oj/problem/problem.html
index 0c82bc6b..a7820ebe 100644
--- a/template/src/oj/problem/problem.html
+++ b/template/src/oj/problem/problem.html
@@ -9,9 +9,6 @@
我的提交
-
- 返回
-
{% include "oj/problem/_problem_header.html" %}
diff --git a/template/src/oj/problem/problem_list.html b/template/src/oj/problem/problem_list.html
index 247b07ff..ed57e168 100644
--- a/template/src/oj/problem/problem_list.html
+++ b/template/src/oj/problem/problem_list.html
@@ -29,8 +29,8 @@
{% for item in problems %}
|
- {{ item.id }} |
- {{ item.title }} |
+ {{ item.id }} |
+ {{ item.title }} |
{{ item.difficulty }} |
{{ item|accepted_radio }} |