File tree Expand file tree Collapse file tree
cms/server/contest/handlers Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -153,6 +153,15 @@ def post(self, task_name: str):
153153 # analysis mode.
154154 official = self .r_params ["actual_phase" ] == 0
155155
156+ # If the submission is performed by the administrator acting on behalf
157+ # of a contestant, allow overriding.
158+ if self .impersonated_by_admin :
159+ try :
160+ official = self .get_boolean_argument ('override_official' , official )
161+ except ValueError as err :
162+ self .json ({"error" : str (err )}, 400 )
163+ return
164+
156165 try :
157166 submission = accept_submission (
158167 self .sql_session , self .service .file_cacher , self .current_user ,
Original file line number Diff line number Diff line change @@ -183,6 +183,20 @@ def is_api(self):
183183 """Return whether it's an API request."""
184184 return self .api_request
185185
186+ def get_boolean_argument (self , name : str , default : bool ) -> bool :
187+ """Parse a Boolean request argument."""
188+
189+ arg = self .get_argument (name , "" )
190+ if arg == "" :
191+ return default
192+
193+ if arg == '0' :
194+ return False
195+ elif arg == '1' :
196+ return True
197+ else :
198+ raise ValueError (f"Cannot parse boolean argument { name } " )
199+
186200
187201class ContestListHandler (BaseHandler ):
188202 def get (self ):
You can’t perform that action at this time.
0 commit comments