File tree 4 files changed +9
-12
lines changed
4 files changed +9
-12
lines changed Original file line number Diff line number Diff line change 14
14
class Contest (models .Model ):
15
15
title = models .TextField ()
16
16
description = RichTextField ()
17
- # show real time rank or cached rank
18
17
password = models .TextField (null = True )
19
- # enum of ContestRuleType
18
+ contest_type = models . TextField ()
20
19
start_time = models .DateTimeField (default = timezone .now ())
21
20
end_time = models .DateTimeField (null = True )
22
21
create_time = models .DateTimeField (auto_now_add = True )
@@ -38,12 +37,6 @@ def status(self):
38
37
# 正在进行 返回0
39
38
return ContestStatus .CONTEST_UNDERWAY
40
39
41
- @property
42
- def contest_type (self ):
43
- if self .password :
44
- return ContestType .PASSWORD_PROTECTED_CONTEST
45
- return ContestType .PUBLIC_CONTEST
46
-
47
40
def problem_details_permission (self , user ):
48
41
return True
49
42
Original file line number Diff line number Diff line change 13
13
from submission .models import Submission , JudgeStatus
14
14
from utils .api import APIView , validate_serializer
15
15
from utils .cache import cache
16
- from utils .constants import CacheKey
16
+ from utils .constants import CacheKey , ContestType
17
17
from utils .shortcuts import rand_str
18
18
from utils .tasks import delete_files
19
19
from ..models import Contest , ContestAnnouncement
@@ -37,8 +37,11 @@ def post(self, request):
37
37
# data["contest_admin"].append(str(request.user.id))
38
38
if data ["end_time" ] <= data ["start_time" ]:
39
39
return self .error ("Start time must occur earlier than end time" )
40
- if data . get ( "password" ) and data ["password" ] == "" :
40
+ if data ["password" ] == "" :
41
41
data ["password" ] = None
42
+ data ["contest_type" ] = ContestType .PUBLIC_CONTEST
43
+ else :
44
+ data ["contest_type" ] = ContestType .PASSWORD_PROTECTED_CONTEST
42
45
for ip_range in data ["allowed_ip_ranges" ]:
43
46
try :
44
47
ip_network (ip_range , strict = False )
Original file line number Diff line number Diff line change @@ -207,7 +207,8 @@ def website_name_shortcut(cls, value):
207
207
208
208
@my_property (ttl = DEFAULT_SHORT_TTL )
209
209
def website_footer (cls ):
210
- return cls ._get_option (OptionKeys .website_footer )
210
+ return ""
211
+ # return cls._get_option(OptionKeys.website_footer)
211
212
212
213
@website_footer .setter
213
214
def website_footer (cls , value ):
Original file line number Diff line number Diff line change @@ -51,7 +51,7 @@ def post(self, request):
51
51
uploader = ZipFileUploader (request .FILES .get ('file' ), problem )
52
52
valid = uploader .upload ()
53
53
if not valid :
54
- return uploader .error_message
54
+ return self . error ( uploader .error_message )
55
55
56
56
# create inexist tags
57
57
for item in tags :
You can’t perform that action at this time.
0 commit comments