Skip to content

Commit 5abc1d2

Browse files
committed
add contest_type in contest models
1 parent 38815cd commit 5abc1d2

File tree

4 files changed

+9
-12
lines changed

4 files changed

+9
-12
lines changed

contest/models.py

+1-8
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@
1414
class Contest(models.Model):
1515
title = models.TextField()
1616
description = RichTextField()
17-
# show real time rank or cached rank
1817
password = models.TextField(null=True)
19-
# enum of ContestRuleType
18+
contest_type = models.TextField()
2019
start_time = models.DateTimeField(default=timezone.now())
2120
end_time = models.DateTimeField(null=True)
2221
create_time = models.DateTimeField(auto_now_add=True)
@@ -38,12 +37,6 @@ def status(self):
3837
# 正在进行 返回0
3938
return ContestStatus.CONTEST_UNDERWAY
4039

41-
@property
42-
def contest_type(self):
43-
if self.password:
44-
return ContestType.PASSWORD_PROTECTED_CONTEST
45-
return ContestType.PUBLIC_CONTEST
46-
4740
def problem_details_permission(self, user):
4841
return True
4942

contest/views/admin.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from submission.models import Submission, JudgeStatus
1414
from utils.api import APIView, validate_serializer
1515
from utils.cache import cache
16-
from utils.constants import CacheKey
16+
from utils.constants import CacheKey, ContestType
1717
from utils.shortcuts import rand_str
1818
from utils.tasks import delete_files
1919
from ..models import Contest, ContestAnnouncement
@@ -37,8 +37,11 @@ def post(self, request):
3737
# data["contest_admin"].append(str(request.user.id))
3838
if data["end_time"] <= data["start_time"]:
3939
return self.error("Start time must occur earlier than end time")
40-
if data.get("password") and data["password"] == "":
40+
if data["password"] == "":
4141
data["password"] = None
42+
data["contest_type"] = ContestType.PUBLIC_CONTEST
43+
else:
44+
data["contest_type"] = ContestType.PASSWORD_PROTECTED_CONTEST
4245
for ip_range in data["allowed_ip_ranges"]:
4346
try:
4447
ip_network(ip_range, strict=False)

options/options.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,8 @@ def website_name_shortcut(cls, value):
207207

208208
@my_property(ttl=DEFAULT_SHORT_TTL)
209209
def website_footer(cls):
210-
return cls._get_option(OptionKeys.website_footer)
210+
return ""
211+
# return cls._get_option(OptionKeys.website_footer)
211212

212213
@website_footer.setter
213214
def website_footer(cls, value):

problem/views/admin.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def post(self, request):
5151
uploader = ZipFileUploader(request.FILES.get('file'), problem)
5252
valid = uploader.upload()
5353
if not valid:
54-
return uploader.error_message
54+
return self.error(uploader.error_message)
5555

5656
# create inexist tags
5757
for item in tags:

0 commit comments

Comments
 (0)