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] =?UTF-8?q?contest=20type=20=E7=9A=84=E8=A1=A8=E7=A4=BA?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E4=BF=AE=E6=94=B9=E4=B8=BA=E5=B8=B8=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"))