Accept Merge Request #225 完成部分任务 : (virusdefender-dev -> dev)

Merge Request: 完成部分任务
Created By: @virusdefender
Accepted By: @virusdefender
URL: https://coding.net/u/virusdefender/p/qduoj/git/merge/225
This commit is contained in:
virusdefender 2015-09-12 09:11:55 +08:00
commit 494c5e4b60
20 changed files with 147 additions and 85 deletions

View File

@ -7,6 +7,11 @@ from problem.models import AbstractProblem
from group.models import Group from group.models import Group
GROUP_CONTEST = 0
PUBLIC_CONTEST = 1
PASSWORD_PUBLIC_CONTEST = 2
class Contest(models.Model): class Contest(models.Model):
title = models.CharField(max_length=40, unique=True) title = models.CharField(max_length=40, unique=True)
description = models.TextField() description = models.TextField()
@ -19,7 +24,8 @@ class Contest(models.Model):
# 只能超级管理员创建公开赛,管理员只能创建小组内部的比赛 # 只能超级管理员创建公开赛,管理员只能创建小组内部的比赛
# 如果这一项不为空,即为有密码的公开赛,没有密码的可以为小组赛或者是公开赛(此时用比赛的类型来表示) # 如果这一项不为空,即为有密码的公开赛,没有密码的可以为小组赛或者是公开赛(此时用比赛的类型来表示)
password = models.CharField(max_length=30, blank=True, null=True) 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() contest_type = models.IntegerField()
# 开始时间 # 开始时间
start_time = models.DateTimeField() start_time = models.DateTimeField()

View File

@ -10,6 +10,7 @@ from account.models import User
from group.models import Group from group.models import Group
from contest.models import Contest, ContestProblem from contest.models import Contest, ContestProblem
from .models import ContestSubmission from .models import ContestSubmission
from .models import GROUP_CONTEST, PUBLIC_CONTEST, PASSWORD_PUBLIC_CONTEST
from announcement.models import Announcement from announcement.models import Announcement
from account.models import REGULAR_USER, ADMIN, SUPER_ADMIN from account.models import REGULAR_USER, ADMIN, SUPER_ADMIN
from decorators import check_user_contest_permission from decorators import check_user_contest_permission
@ -32,15 +33,17 @@ class ContestAdminAPITest(APITestCase):
join_group_setting=0, visible=True, join_group_setting=0, visible=True,
admin=user2) admin=user2)
self.group2 = Group.objects.create(name="group2", description="des0", self.group2 = Group.objects.create(name="group2", description="des0",
join_group_setting=0, visible=True, join_group_setting=0, visible=True,
admin=user1) admin=user1)
self.global_contest = Contest.objects.create(title="titlex", description="descriptionx", mode=1, 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", start_time="2015-08-15T10:00:00.000Z",
end_time="2015-08-15T12:00:00.000Z", end_time="2015-08-15T12:00:00.000Z",
password="aacc", created_by=User.objects.get(username="test1")) password="aacc", created_by=User.objects.get(username="test1"))
self.group_contest = Contest.objects.create(title="titley", description="descriptiony", mode=1, 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", start_time="2015-08-15T10:00:00.000Z",
end_time="2015-08-15T12:00:00.000Z", end_time="2015-08-15T12:00:00.000Z",
password="aacc", created_by=User.objects.get(username="test1")) 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): def test_global_contest_does_not_has_privileges(self):
self.client.login(username="test2", password="testbb") 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", "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} "end_time": "2015-08-15T12:00:00.000Z", "password": "aabb", "visible": True}
response = self.client.post(self.url, data=data) response = self.client.post(self.url, data=data)
@ -62,7 +65,7 @@ class ContestAdminAPITest(APITestCase):
def test_global_contest_password_exists(self): def test_global_contest_password_exists(self):
self.client.login(username="test1", password="testaa") 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", "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} "end_time": "2015-08-15T12:00:00.000Z", "visible": True}
response = self.client.post(self.url, data=data) response = self.client.post(self.url, data=data)
@ -70,7 +73,7 @@ class ContestAdminAPITest(APITestCase):
def test_group_contest_group_at_least_one(self): def test_group_contest_group_at_least_one(self):
self.client.login(username="test1", password="testaa") 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", "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} "end_time": "2015-08-15T12:00:00.000Z", "visible": True}
response = self.client.post(self.url, data=data) response = self.client.post(self.url, data=data)
@ -78,7 +81,7 @@ class ContestAdminAPITest(APITestCase):
def test_global_contest_successfully(self): def test_global_contest_successfully(self):
self.client.login(username="test1", password="testaa") 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", "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} "end_time": "2015-08-15T12:00:00.000Z", "password": "aabb", "visible": True}
response = self.client.post(self.url, data=data) response = self.client.post(self.url, data=data)
@ -86,7 +89,7 @@ class ContestAdminAPITest(APITestCase):
def test_group_contest_super_admin_successfully(self): def test_group_contest_super_admin_successfully(self):
self.client.login(username="test1", password="testaa") 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", "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} "end_time": "2015-08-15T12:00:00.000Z", "groups": [self.group.id], "visible": True}
response = self.client.post(self.url, data=data) response = self.client.post(self.url, data=data)
@ -94,7 +97,7 @@ class ContestAdminAPITest(APITestCase):
def test_group_contest_admin_successfully(self): def test_group_contest_admin_successfully(self):
self.client.login(username="test2", password="testbb") 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", "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} "end_time": "2015-08-15T12:00:00.000Z", "groups": [self.group.id], "visible": True}
response = self.client.post(self.url, data=data) response = self.client.post(self.url, data=data)
@ -102,7 +105,7 @@ class ContestAdminAPITest(APITestCase):
def test_time_error(self): def test_time_error(self):
self.client.login(username="test1", password="testaa") 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", "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} "end_time": "2015-08-15T10:00:00.000Z", "password": "aabb", "visible": True}
response = self.client.post(self.url, data=data) response = self.client.post(self.url, data=data)
@ -110,7 +113,7 @@ class ContestAdminAPITest(APITestCase):
def test_contest_has_exists(self): def test_contest_has_exists(self):
self.client.login(username="test1", password="testaa") 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", "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} "end_time": "2015-08-15T12:00:00.000Z", "password": "aabb", "visible": True}
response = self.client.post(self.url, data=data) response = self.client.post(self.url, data=data)
@ -126,7 +129,7 @@ class ContestAdminAPITest(APITestCase):
def test_contest_does_not_exist(self): def test_contest_does_not_exist(self):
self.client.login(username="test1", password="testaa") self.client.login(username="test1", password="testaa")
data = {"id": self.global_contest.id + 10, "title": "title2", "description": "description2", "mode": 1, 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", "start_time": "2015-08-15T10:00:00.000Z", "end_time": "2015-08-15T12:00:00.000Z", "password": "aabb",
"visible": True} "visible": True}
response = self.client.put(self.url, data=data) response = self.client.put(self.url, data=data)
@ -135,7 +138,7 @@ class ContestAdminAPITest(APITestCase):
def test_edit_global_contest_successfully(self): def test_edit_global_contest_successfully(self):
self.client.login(username="test1", password="testaa") self.client.login(username="test1", password="testaa")
data = {"id": self.global_contest.id, "title": "titlez", "description": "descriptionz", "mode": 1, 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", "start_time": "2015-08-15T10:00:00.000Z", "end_time": "2015-08-15T13:00:00.000Z", "password": "aabb",
"visible": True} "visible": True}
response = self.client.put(self.url, data=data) response = self.client.put(self.url, data=data)
@ -146,7 +149,7 @@ class ContestAdminAPITest(APITestCase):
def test_edit_group_contest_successfully(self): def test_edit_group_contest_successfully(self):
self.client.login(username="test1", password="testaa") self.client.login(username="test1", password="testaa")
data = {"id": self.group_contest.id, "title": "titleyyy", "description": "descriptionyyyy", "mode": 1, 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", "start_time": "2015-08-15T10:00:00.000Z", "end_time": "2015-08-15T13:00:00.000Z",
"groups": [self.group.id], "visible": False} "groups": [self.group.id], "visible": False}
response = self.client.put(self.url, data=data) response = self.client.put(self.url, data=data)
@ -158,7 +161,7 @@ class ContestAdminAPITest(APITestCase):
def test_edit_group_contest_unsuccessfully(self): def test_edit_group_contest_unsuccessfully(self):
self.client.login(username="test2", password="testbb") self.client.login(username="test2", password="testbb")
data = {"id": self.group_contest.id, "title": "titleyyy", "description": "descriptionyyyy", "mode": 1, 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", "start_time": "2015-08-15T10:00:00.000Z", "end_time": "2015-08-15T13:00:00.000Z",
"groups": [self.group.id], "visible": False} "groups": [self.group.id], "visible": False}
response = self.client.put(self.url, data=data) response = self.client.put(self.url, data=data)
@ -167,7 +170,7 @@ class ContestAdminAPITest(APITestCase):
def test_edit_group_at_least_one(self): def test_edit_group_at_least_one(self):
self.client.login(username="test1", password="testaa") self.client.login(username="test1", password="testaa")
data = {"id": self.group_contest.id, "title": "titleyyy", "description": "descriptionyyyy", "mode": 1, 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} "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) response = self.client.put(self.url, data=data)
self.assertEqual(response.data, {"code": 1, "data": u"请至少选择一个小组"}) self.assertEqual(response.data, {"code": 1, "data": u"请至少选择一个小组"})
@ -175,7 +178,7 @@ class ContestAdminAPITest(APITestCase):
def test_edit_contest_has_exists(self): def test_edit_contest_has_exists(self):
self.client.login(username="test1", password="testaa") self.client.login(username="test1", password="testaa")
data = {"id": self.global_contest.id, "title": "titley", "description": "descriptiony", "mode": 1, 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", "start_time": "2015-08-15T10:00:00.000Z", "end_time": "2015-08-15T12:00:00.000Z", "password": "aabb",
"visible": True} "visible": True}
response = self.client.put(self.url, data=data) 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): def test_edit_global_contest_does_not_has_privileges(self):
self.client.login(username="test2", password="testbb") self.client.login(username="test2", password="testbb")
data = {"id": self.global_contest.id, "title": "titlexxxxxxxxx", "description": "descriptionxxxxxx", "mode": 1, 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", "start_time": "2015-08-15T10:00:00.000Z", "end_time": "2015-08-15T12:00:00.000Z", "password": "aabb",
"visible": True} "visible": True}
response = self.client.put(self.url, data=data) response = self.client.put(self.url, data=data)
@ -193,8 +196,7 @@ class ContestAdminAPITest(APITestCase):
def test_edit_global_contest_password_exists(self): def test_edit_global_contest_password_exists(self):
self.client.login(username="test1", password="testaa") self.client.login(username="test1", password="testaa")
data = {"id": self.global_contest.id, "title": "title0", "description": "description0", "mode": 1, data = {"id": self.global_contest.id, "title": "title0", "description": "description0", "mode": 1,
"contest_type": 2, "contest_type": PASSWORD_PUBLIC_CONTEST, "show_rank": True, "show_user_submission": True, "start_time": "2015-08-15T10:00:00.000Z",
"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} "end_time": "2015-08-15T12:00:00.000Z", "visible": True}
response = self.client.put(self.url, data=data) response = self.client.put(self.url, data=data)
self.assertEqual(response.data, {"code": 1, "data": u"此比赛为有密码的公开赛,密码不可为空"}) self.assertEqual(response.data, {"code": 1, "data": u"此比赛为有密码的公开赛,密码不可为空"})
@ -202,7 +204,7 @@ class ContestAdminAPITest(APITestCase):
def test_edit_time_error(self): def test_edit_time_error(self):
self.client.login(username="test1", password="testaa") self.client.login(username="test1", password="testaa")
data = {"id": self.global_contest.id, "title": "titleaaaa", "description": "descriptionaaaaa", "mode": 1, 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", "start_time": "2015-08-15T12:00:00.000Z", "end_time": "2015-08-15T10:00:00.000Z", "password": "aabb",
"visible": True} "visible": True}
response = self.client.put(self.url, data=data) response = self.client.put(self.url, data=data)
@ -245,7 +247,8 @@ class ContestProblemAdminAPItEST(APITestCase):
self.user3.save() self.user3.save()
self.client.login(username="test1", password="testaa") self.client.login(username="test1", password="testaa")
self.global_contest = Contest.objects.create(title="titlex", description="descriptionx", mode=1, 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", start_time="2015-08-15T10:00:00.000Z",
end_time="2015-08-15T12:00:00.000Z", end_time="2015-08-15T12:00:00.000Z",
password="aacc", created_by=User.objects.get(username="test1")) 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): def test_query_contest_problem_exists_by_contest_id(self):
self.client.login(username="test3", password="testaa") 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(response.data["code"], 0)
self.assertEqual(len(response.data["data"]), 0) self.assertEqual(len(response.data["data"]), 0)
@ -414,7 +417,8 @@ class ContestPasswordVerifyAPITest(APITestCase):
self.user2.save() self.user2.save()
self.client.login(username="test1", password="testaa") self.client.login(username="test1", password="testaa")
self.global_contest = Contest.objects.create(title="titlex", description="descriptionx", mode=1, 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", start_time="2015-08-15T10:00:00.000Z",
end_time="2015-08-15T12:00:00.000Z", end_time="2015-08-15T12:00:00.000Z",
password="aacc", created_by=User.objects.get(username="test1")) password="aacc", created_by=User.objects.get(username="test1"))
@ -453,7 +457,8 @@ class ContestPageTest(TestCase):
self.user1.save() self.user1.save()
self.client.login(username="test1", password="testaa") self.client.login(username="test1", password="testaa")
self.global_contest = Contest.objects.create(title="titlex", description="descriptionx", mode=1, 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", start_time="2015-08-15T10:00:00.000Z",
end_time="2015-08-15T12:00:00.000Z", end_time="2015-08-15T12:00:00.000Z",
password="aacc", created_by=User.objects.get(username="test1")) password="aacc", created_by=User.objects.get(username="test1"))
@ -476,7 +481,8 @@ class ContestProblemPageTest(TestCase):
self.user1.save() self.user1.save()
self.client.login(username="test1", password="testaa") self.client.login(username="test1", password="testaa")
self.global_contest = Contest.objects.create(title="titlex", description="descriptionx", mode=1, 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", start_time="2015-08-15T10:00:00.000Z",
end_time="2015-08-15T12:00:00.000Z", end_time="2015-08-15T12:00:00.000Z",
password="aacc", created_by=User.objects.get(username="test1")) password="aacc", created_by=User.objects.get(username="test1"))
@ -519,7 +525,8 @@ class ContestProblemListPageTest(TestCase):
self.user1.save() self.user1.save()
self.client.login(username="test1", password="testaa") self.client.login(username="test1", password="testaa")
self.global_contest = Contest.objects.create(title="titlex", description="descriptionx", mode=1, 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", start_time="2015-08-15T10:00:00.000Z",
end_time="2015-08-15T12:00:00.000Z", end_time="2015-08-15T12:00:00.000Z",
password="aacc", created_by=User.objects.get(username="test1")) password="aacc", created_by=User.objects.get(username="test1"))
@ -555,7 +562,8 @@ class ContestListPageTest(TestCase):
self.url = reverse('contest_list_page') self.url = reverse('contest_list_page')
self.client.login(username="test1", password="testaa") self.client.login(username="test1", password="testaa")
self.global_contest = Contest.objects.create(title="titlex", description="descriptionx", mode=1, 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", start_time="2015-08-15T10:00:00.000Z",
end_time="2015-08-15T12:00:00.000Z", end_time="2015-08-15T12:00:00.000Z",
password="aacc", created_by=User.objects.get(username="test1")) password="aacc", created_by=User.objects.get(username="test1"))

View File

@ -18,6 +18,7 @@ from group.models import Group
from announcement.models import Announcement from announcement.models import Announcement
from .models import Contest, ContestProblem, ContestSubmission from .models import Contest, ContestProblem, ContestSubmission
from .models import GROUP_CONTEST, PUBLIC_CONTEST, PASSWORD_PUBLIC_CONTEST
from .decorators import check_user_contest_permission from .decorators import check_user_contest_permission
from .serializers import (CreateContestSerializer, ContestSerializer, EditContestSerializer, from .serializers import (CreateContestSerializer, ContestSerializer, EditContestSerializer,
CreateContestProblemSerializer, ContestProblemSerializer, CreateContestProblemSerializer, ContestProblemSerializer,
@ -37,17 +38,18 @@ class ContestAdminAPIView(APIView):
if serializer.is_valid(): if serializer.is_valid():
data = serializer.data data = serializer.data
groups = [] 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: if request.user.admin_type != SUPER_ADMIN:
return error_response(u"只有超级管理员才可创建公开赛") return error_response(u"只有超级管理员才可创建公开赛")
if data["contest_type"] == 2: if data["contest_type"] == PASSWORD_PUBLIC_CONTEST:
if not data["password"]: if not data["password"]:
return error_response(u"此比赛为有密码的公开赛,密码不可为空") return error_response(u"此比赛为有密码的公开赛,密码不可为空")
# 没有密码的公开赛 没有密码的小组赛 # 没有密码的公开赛 没有密码的小组赛
elif data["contest_type"] == 0: elif data["contest_type"] == GROUP_CONTEST:
if request.user.admin_type == SUPER_ADMIN: if request.user.admin_type == SUPER_ADMIN:
groups = Group.objects.filter(id__in=data["groups"]) groups = Group.objects.filter(id__in=data["groups"])
else: else:
@ -92,13 +94,13 @@ class ContestAdminAPIView(APIView):
return error_response(u"该比赛名称已经存在") return error_response(u"该比赛名称已经存在")
except Contest.DoesNotExist: except Contest.DoesNotExist:
pass 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: if request.user.admin_type != SUPER_ADMIN:
return error_response(u"只有超级管理员才可创建公开赛") return error_response(u"只有超级管理员才可创建公开赛")
if data["contest_type"] == 2: if data["contest_type"] == PASSWORD_PUBLIC_CONTEST:
if not data["password"]: if not data["password"]:
return error_response(u"此比赛为有密码的公开赛,密码不可为空") return error_response(u"此比赛为有密码的公开赛,密码不可为空")
elif data["contest_type"] == 0: elif data["contest_type"] == GROUP_CONTEST:
if request.user.admin_type == SUPER_ADMIN: if request.user.admin_type == SUPER_ADMIN:
groups = Group.objects.filter(id__in=data["groups"]) groups = Group.objects.filter(id__in=data["groups"])
else: else:
@ -256,7 +258,7 @@ class ContestPasswordVerifyAPIView(APIView):
if serializer.is_valid(): if serializer.is_valid():
data = request.data data = request.data
try: 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: except Contest.DoesNotExist:
return error_response(u"比赛不存在") return error_response(u"比赛不存在")
@ -333,10 +335,7 @@ def contest_problems_list_page(request, contest_id):
item.state = 2 item.state = 2
else: else:
item.state = 0 item.state = 0
# 右侧的公告列表
announcements = Announcement.objects.filter(is_global=True, visible=True).order_by("-create_time")
return render(request, "oj/contest/contest_problems_list.html", {"contest_problems": contest_problems, return render(request, "oj/contest/contest_problems_list.html", {"contest_problems": contest_problems,
"announcements": announcements,
"contest": {"id": contest_id}}) "contest": {"id": contest_id}})
@ -355,7 +354,7 @@ def contest_list_page(request, page=1):
# 筛选我能参加的比赛 # 筛选我能参加的比赛
join = request.GET.get("join", None) join = request.GET.get("join", None)
if join: 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()) filter(end_time__gt=datetime.datetime.now(), start_time__lt=datetime.datetime.now())
paginator = Paginator(contests, 20) paginator = Paginator(contests, 20)
@ -376,14 +375,10 @@ def contest_list_page(request, page=1):
except Exception: except Exception:
pass pass
# 右侧的公告列表
announcements = Announcement.objects.filter(is_global=True, visible=True).order_by("-create_time")
return render(request, "oj/contest/contest_list.html", return render(request, "oj/contest/contest_list.html",
{"contests": current_page, "page": int(page), {"contests": current_page, "page": int(page),
"previous_page": previous_page, "next_page": next_page, "previous_page": previous_page, "next_page": next_page,
"keyword": keyword, "announcements": announcements, "keyword": keyword, "join": join})
"join": join})
def _cmp(x, y): def _cmp(x, y):

View File

@ -5,6 +5,7 @@ from django.core.urlresolvers import reverse
from account.models import User, REGULAR_USER, ADMIN, SUPER_ADMIN from account.models import User, REGULAR_USER, ADMIN, SUPER_ADMIN
from problem.models import Problem from problem.models import Problem
from contest.models import Contest, ContestProblem from contest.models import Contest, ContestProblem
from contest.models import GROUP_CONTEST, PUBLIC_CONTEST, PASSWORD_PUBLIC_CONTEST
from submission.models import Submission from submission.models import Submission
from rest_framework.test import APITestCase, APIClient from rest_framework.test import APITestCase, APIClient
@ -20,7 +21,8 @@ class ContestSubmissionAPITest(APITestCase):
self.user2.set_password("testbb") self.user2.set_password("testbb")
self.user2.save() self.user2.save()
self.global_contest = Contest.objects.create(title="titlex", description="descriptionx", mode=1, 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", start_time="2015-08-15T10:00:00.000Z",
end_time="2015-08-30T12:00:00.000Z", end_time="2015-08-30T12:00:00.000Z",
created_by=User.objects.get(username="test1")) created_by=User.objects.get(username="test1"))
@ -70,7 +72,8 @@ class ContestProblemMySubmissionListTest(TestCase):
self.user2.set_password("testbb") self.user2.set_password("testbb")
self.user2.save() self.user2.save()
self.global_contest = Contest.objects.create(title="titlex", description="descriptionx", mode=1, 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", start_time="2015-08-15T10:00:00.000Z",
end_time="2015-08-30T12:00:00.000Z", end_time="2015-08-30T12:00:00.000Z",
created_by=User.objects.get(username="test1")) created_by=User.objects.get(username="test1"))
@ -104,7 +107,8 @@ class SubmissionAPITest(APITestCase):
self.userS.set_password("testbb") self.userS.set_password("testbb")
self.userS.save() self.userS.save()
self.global_contest = Contest.objects.create(title="titlex", description="descriptionx", mode=1, 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", start_time="2015-08-15T10:00:00.000Z",
end_time="2015-08-15T12:00:00.000Z", end_time="2015-08-15T12:00:00.000Z",
password="aacc", created_by=self.userS password="aacc", created_by=self.userS

View File

@ -254,9 +254,6 @@ class JoinGroupRequestAdminAPIView(APIView, GroupAPIViewBase):
@login_required @login_required
def group_list_page(request, page=1): def group_list_page(request, page=1):
# 右侧的公告列表
announcements = Announcement.objects.filter(is_global=True, visible=True).order_by("-create_time")
groups = Group.objects.filter(visible=True, join_group_setting__lte=2) groups = Group.objects.filter(visible=True, join_group_setting__lte=2)
# 搜索的情况 # 搜索的情况
keyword = request.GET.get("keyword", None) keyword = request.GET.get("keyword", None)
@ -282,10 +279,10 @@ def group_list_page(request, page=1):
pass pass
return render(request, "oj/group/group_list.html", { return render(request, "oj/group/group_list.html", {
"groups": groups, "announcements": announcements, "groups": groups,
"contests": current_page, "page": int(page), "contests": current_page, "page": int(page),
"previous_page": previous_page, "next_page": next_page, "previous_page": previous_page, "next_page": next_page,
"keyword": keyword, "announcements": announcements, "keyword": keyword
}) })

View File

@ -228,6 +228,19 @@ def problem_list_page(request, page=1):
if keyword: if keyword:
problems = problems.filter(Q(title__contains=keyword) | Q(description__contains=keyword)) problems = problems.filter(Q(title__contains=keyword) | Q(description__contains=keyword))
difficulty_order = request.GET.get("order_by", None)
if difficulty_order:
if difficulty_order[0] == "-":
problems = problems.order_by("-difficulty")
difficulty_order = "difficulty"
else:
problems = problems.order_by("difficulty")
difficulty_order = "-difficulty"
else:
difficulty_order = "difficulty"
# 按照标签筛选 # 按照标签筛选
tag_text = request.GET.get("tag", None) tag_text = request.GET.get("tag", None)
if tag_text: if tag_text:
@ -255,8 +268,6 @@ def problem_list_page(request, page=1):
except Exception: except Exception:
pass pass
# 右侧的公告列表
announcements = Announcement.objects.filter(is_global=True, visible=True).order_by("-create_time")
# 右侧标签列表 按照关联的题目的数量排序 排除题目数量为0的 # 右侧标签列表 按照关联的题目的数量排序 排除题目数量为0的
tags = ProblemTag.objects.annotate(problem_number=Count("problem")).filter(problem_number__gt=0).order_by("-problem_number") tags = ProblemTag.objects.annotate(problem_number=Count("problem")).filter(problem_number__gt=0).order_by("-problem_number")
@ -264,4 +275,4 @@ def problem_list_page(request, page=1):
{"problems": current_page, "page": int(page), {"problems": current_page, "page": int(page),
"previous_page": previous_page, "next_page": next_page, "previous_page": previous_page, "next_page": next_page,
"keyword": keyword, "tag": tag_text, "keyword": keyword, "tag": tag_text,
"announcements": announcements, "tags": tags}) "tags": tags, "difficulty_order": difficulty_order})

View File

@ -103,4 +103,8 @@ li.list-group-item {
#share-code textarea { #share-code textarea {
margin-top: 15px; margin-top: 15px;
}
#about-acm-logo{
width: 40%;
} }

BIN
static/src/img/acm_logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 500 KiB

View File

@ -1,15 +1,32 @@
require(["jquery", "codeMirror", "csrfToken", "bsAlert", "ZeroClipboard"], require(["jquery", "codeMirror", "csrfToken", "bsAlert", "ZeroClipboard"],
function ($, codeMirror, csrfTokenHeader, bsAlert, ZeroClipboard) { function ($, codeMirror, csrfTokenHeader, bsAlert, ZeroClipboard) {
// 复制样例需要 Flash 的支持 检测浏览器是否安装了 Flash
function detect_flash() {
var ie_flash;
try {
ie_flash = (window.ActiveXObject && (new ActiveXObject("ShockwaveFlash.ShockwaveFlash")) !== false)
} catch (err) {
ie_flash = false;
}
var _flash_installed = ((typeof navigator.plugins != "undefined" && typeof navigator.plugins["Shockwave Flash"] == "object") || ie_flash);
return _flash_installed;
}
if(detect_flash()) {
// 提供点击复制到剪切板的功能
ZeroClipboard.config({swfPath: "/static/img/ZeroClipboard.swf"});
new ZeroClipboard($(".copy-sample"));
}
else{
$(".copy-sample").hide();
}
var codeEditorSelector = $("#code-editor")[0]; var codeEditorSelector = $("#code-editor")[0];
// 部分界面逻辑会隐藏代码输入框,先判断有没有。 // 部分界面逻辑会隐藏代码输入框,先判断有没有。
if (codeEditorSelector == undefined) { if (codeEditorSelector == undefined) {
return; return;
} }
// 提供点击复制到剪切板的功能
ZeroClipboard.config({swfPath: "/static/img/ZeroClipboard.swf"});
new ZeroClipboard($(".copy-sample"));
var codeEditor = codeMirror(codeEditorSelector, "text/x-csrc"); var codeEditor = codeMirror(codeEditorSelector, "text/x-csrc");
var language = $("input[name='language'][checked]").val(); var language = $("input[name='language'][checked]").val();
var submissionId; var submissionId;
@ -186,4 +203,4 @@ require(["jquery", "codeMirror", "csrfToken", "bsAlert", "ZeroClipboard"],
} }
} }
}) })
}); });

View File

@ -5,6 +5,7 @@ from django.core.urlresolvers import reverse
from account.models import User, REGULAR_USER, ADMIN, SUPER_ADMIN from account.models import User, REGULAR_USER, ADMIN, SUPER_ADMIN
from problem.models import Problem from problem.models import Problem
from contest.models import Contest from contest.models import Contest
from contest.models import GROUP_CONTEST, PUBLIC_CONTEST, PASSWORD_PUBLIC_CONTEST
from submission.models import Submission from submission.models import Submission
from rest_framework.test import APITestCase, APIClient from rest_framework.test import APITestCase, APIClient
@ -82,7 +83,8 @@ class SubmissionAPITest(APITestCase):
hint="hint1", hint="hint1",
created_by=User.objects.get(username="test2")) created_by=User.objects.get(username="test2"))
self.global_contest = Contest.objects.create(title="titlex", description="descriptionx", mode=1, 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", start_time="2015-08-15T10:00:00.000Z",
end_time="2015-08-15T12:00:00.000Z", end_time="2015-08-15T12:00:00.000Z",
password="aacc", created_by=User.objects.get(username="test2")) password="aacc", created_by=User.objects.get(username="test2"))
@ -151,7 +153,8 @@ class SubmissionAdminAPITest(APITestCase):
hint="hint1", hint="hint1",
created_by=self.user) created_by=self.user)
self.global_contest = Contest.objects.create(title="titlex", description="descriptionx", mode=1, 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", start_time="2015-08-15T10:00:00.000Z",
end_time="2015-08-15T12:00:00.000Z", end_time="2015-08-15T12:00:00.000Z",
password="aacc", created_by=self.user) password="aacc", created_by=self.user)
@ -190,7 +193,8 @@ class SubmissionPageTest(TestCase):
hint="hint1", hint="hint1",
created_by=User.objects.get(username="test1")) created_by=User.objects.get(username="test1"))
self.global_contest = Contest.objects.create(title="titlex", description="descriptionx", mode=1, 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", start_time="2015-08-15T10:00:00.000Z",
end_time="2015-08-15T12:00:00.000Z", end_time="2015-08-15T12:00:00.000Z",
password="aacc", created_by=User.objects.get(username="test1")) password="aacc", created_by=User.objects.get(username="test1"))

View File

@ -165,6 +165,16 @@ def my_submission_list_page(request, page=1):
if result: if result:
submissions = submissions.filter(result=int(result)) submissions = submissions.filter(result=int(result))
filter = {"name": "result", "content": 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) paginator = Paginator(submissions, 20)
try: try:
current_page = paginator.page(int(page)) current_page = paginator.page(int(page))

View File

@ -1,3 +1,4 @@
{% load announcement_list %}
<div class="panel panel-info"> <div class="panel panel-info">
<div class="panel-heading"> <div class="panel-heading">
<h3 class="panel-title"> <h3 class="panel-title">
@ -5,8 +6,9 @@
公告 公告
</h3></div> </h3></div>
<div class="panel-body"> <div class="panel-body">
{% public_announcement_list as announcements %}
{% if announcements %} {% if announcements %}
{% for item in announcements %} {% for item in announcements%}
<p>{{ forloop.counter }}.&nbsp;&nbsp;<a href="/announcement/{{ item.id }}/" target="_blank">{{ item.title }}</a> <p>{{ forloop.counter }}.&nbsp;&nbsp;<a href="/announcement/{{ item.id }}/" target="_blank">{{ item.title }}</a>
</p> </p>
{% endfor %} {% endfor %}

View File

@ -33,6 +33,6 @@
</tbody> </tbody>
</table> </table>
<hr> <hr>
<div>{{ contest.description|safe }}</div> <div class="text-center">{{ contest.description|safe }}</div>
</div> </div>
<p class="text-center"></p> <p class="text-center"></p>

View File

@ -8,9 +8,6 @@
<li role="presentation"><a <li role="presentation"><a
href="/contest/{{ contest_problem.contest.id }}/problem/{{ contest_problem.id }}/submissions/">我的提交</a> href="/contest/{{ contest_problem.contest.id }}/problem/{{ contest_problem.id }}/submissions/">我的提交</a>
</li> </li>
<li role="presentation"><a
href="/contest/{{ contest_problem.contest.id }}/problems/">返回</a>
</li>
</ul> </ul>
<h2 class="text-center">{{ contest_problem.title }}</h2> <h2 class="text-center">{{ contest_problem.title }}</h2>
@ -40,6 +37,7 @@
{% for item in samples %} {% for item in samples %}
<div class="problem-section"> <div class="problem-section">
<label class="problem-label">样例输入{{ forloop.counter }}</label> <label class="problem-label">样例输入{{ forloop.counter }}</label>
<a href="javascript:void(0)" class="copy-sample" data-clipboard-text="{{ item.input }}">复制</a>
<pre> <pre>
{{ item.input }}</pre> {{ item.input }}</pre>

View File

@ -57,10 +57,10 @@
</th> </th>
<th scope="row"> <th scope="row">
<a href="/contest/{{ item.contest.id }}/problem/{{ item.id }}/" target="_blank">{{ item.sort_index }}</a> <a href="/contest/{{ item.contest.id }}/problem/{{ item.id }}/">{{ item.sort_index }}</a>
</th> </th>
<td> <td>
<a href="/contest/{{ item.contest.id }}/problem/{{ item.id }}/" target="_blank">{{ item.title }}</a> <a href="/contest/{{ item.contest.id }}/problem/{{ item.id }}/">{{ item.title }}</a>
</td> </td>
<td>{{ item|accepted_radio }}</td> <td>{{ item|accepted_radio }}</td>
</tr> </tr>

View File

@ -9,9 +9,6 @@
<li role="presentation"> <li role="presentation">
<a href="/problem/{{ problem.id }}/submissions/">我的提交</a> <a href="/problem/{{ problem.id }}/submissions/">我的提交</a>
</li> </li>
<li role="presentation">
<a href="/problems/">返回</a>
</li>
</ul> </ul>
{% include "oj/problem/_problem_header.html" %} {% include "oj/problem/_problem_header.html" %}

View File

@ -21,16 +21,16 @@
<th></th> <th></th>
<th>#</th> <th>#</th>
<th>题目</th> <th>题目</th>
<th><a href="/problems/?order_by=difficulty">难度</a></th> <th><a href="/problems/?order_by={{ difficulty_order }}">难度</a></th>
<th><a href="/problems/?order_by=acceptance">通过率</a></th> <th>通过率</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{% for item in problems %} {% for item in 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 href="/problem/{{ item.id }}/" target="_blank">{{ item.id }}</a></th> <th scope="row"><a href="/problem/{{ item.id }}/">{{ item.id }}</a></th>
<td><a href="/problem/{{ item.id }}/" target="_blank">{{ item.title }}</a></td> <td><a href="/problem/{{ item.id }}/">{{ item.title }}</a></td>
<td>{{ item.difficulty }}</td> <td>{{ item.difficulty }}</td>
<td>{{ item|accepted_radio }}</td> <td>{{ item|accepted_radio }}</td>
</tr> </tr>

View File

@ -3,7 +3,7 @@
{% block body %} {% block body %}
{% load submission %} {% load submission %}
<div class="container main"> <div class="container main">
<div class="col-md-9 col-lg-9"> <div class="col-md-12 col-lg-12">
<table class="table table-striped"> <table class="table table-striped">
<thead> <thead>
<tr> <tr>
@ -52,7 +52,7 @@
<a href="/submission/{{ item.id }}/">{{ forloop.counter |add:start_id }}</a> <a href="/submission/{{ item.id }}/">{{ forloop.counter |add:start_id }}</a>
</th> </th>
<td> <td>
<a href="/problem/{{ item.problem_id }}/">{{ item.problem_id }}</a> <a href="/problem/{{ item.problem_id }}/">{{ item.title }}</a>
</td> </td>
<td>{{ item.create_time }}</td> <td>{{ item.create_time }}</td>
<td> <td>
@ -92,8 +92,6 @@
<p>你还没有提交记录!</p> <p>你还没有提交记录!</p>
{% endif %} {% endif %}
</div> </div>
<div class="col-md-3 col-lg-3">
{% include "oj/announcement/_announcement_panel.html" %}
</div>
</div> </div>
{% endblock %} {% endblock %}

View File

@ -11,6 +11,7 @@
</ul> </ul>
<div> <div>
<h2 class="text-center">ACM 简介</h2> <h2 class="text-center">ACM 简介</h2>
<img src="/static/img/acm_logo.png" id="about-acm-logo" class="center-block">
<p> <p>
ACM国际大学生程序设计竞赛英语ACM International Collegiate Programming Contest, ACM国际大学生程序设计竞赛英语ACM International Collegiate Programming Contest,

View File

@ -0,0 +1,10 @@
# coding=utf-8
from django import template
from announcement.models import Announcement
def public_announcement_list():
return Announcement.objects.filter(is_global=True, visible=True).order_by("-create_time")
register = template.Library()
register.assignment_tag(public_announcement_list, name="public_announcement_list")