Example #1
0
 def clean( self ):
     cleaned_data = super().clean()
     problemslug = cleaned_data.get( 'problemslug' )
     code = cleaned_data.get( 'code' )
     language = Language.get_language( cleaned_data.get( 'language' ) )
     s = get_object_or_None( Problem , slug = problemslug )
     if problemslug and s is None:
         self.add_error( 'problemslug' , 'Problem not exists.' )
     if language is None:
         self.add_error( 'language' , 'Unknown language' )
Example #2
0
 async def init(self):
     s = await database_sync_to_async(Judgeinfo.objects.filter
                                      )(submission=self.submission)
     lang = Language.get_language(self.submission.language)
     await self.update_result(
         event={
             'data': {
                 'result':
                 self.submission.judge_status,
                 'judge': [each.get_websocket_field() for each in s],
                 'compileerror_msg':
                 self.submission.compileerror_msg,
                 'judgererror_msg':
                 self.submission.judgererror_msg,
                 'completed':
                 self.submission.completed,
                 'code':
                 self.submission.code,
                 'casenumber':
                 self.submission.case_number,
                 'codehighlight':
                 lang.value.codemirror,
                 'completed':
                 self.submission.completed,
                 'problem__title':
                 self.submission.problem.title,
                 'problem__slug':
                 self.submission.problem.slug,
                 'user__display_name':
                 self.submission.user.display_name,
                 'user__username':
                 self.submission.user.username,
                 'submit_time':
                 self.submission.submit_time.strftime("%Y-%m-%d %H:%M:%S"),
             }
         })