def updateContest(self, contestTitle, pInfos, startTime, contestDesc='', length=300, boardStop=300, contestType=0, boardType=0, lang_limit=0): self.contest_title = contestTitle self._vTitle() if self.start_time != startTime: self.start_time = startTime self._vStartTime() self.length = length self._vLength() self.board_stop = boardStop self._vBoardStop() self.contest_description = contestDesc self.contest_type = contestType self.board_type = boardType self.lang_limit = lang_limit self.save() # To be modified, URGENT try: self._vStartTime() except: return True map(lambda x: x.delete(), ContestProblem.objects.filter(contest=self)) for pInfo in pInfos: try: prob = Problem.objects.get(pid=pInfo[0]) except: raise Exception(Const.CONTEST_PROB_ERR) ## try: ## contestProb = ContestProblem.objects.get(contest=self, problem=prob) ## except: ## contestProb = ContestProblem() ## contestProb.contest = self ## contestProb.problem = prob contestProb = ContestProblem() contestProb.contest = self contestProb.problem = prob if not Problem.isLegalTitle(pInfo[1]) or len(pInfo[1]) == 0: contestProb.problem_title = contestProb.problem.prob_title else: contestProb.problem_title = pInfo[1] contestProb.problem_index = pInfo[2] contestProb.save() return True
def updateContest( self, contestTitle, pInfos, startTime, contestDesc="", length=300, boardStop=300, contestType=0, boardType=0, lang_limit=0, ): self.contest_title = contestTitle self._vTitle() if self.start_time != startTime: self.start_time = startTime self._vStartTime() self.length = length self._vLength() self.board_stop = boardStop self._vBoardStop() self.contest_description = contestDesc self.contest_type = contestType self.board_type = boardType self.lang_limit = lang_limit self.save() # To be modified, URGENT try: self._vStartTime() except: return True map(lambda x: x.delete(), ContestProblem.objects.filter(contest=self)) for pInfo in pInfos: try: prob = Problem.objects.get(pid=pInfo[0]) except: raise Exception(Const.CONTEST_PROB_ERR) ## try: ## contestProb = ContestProblem.objects.get(contest=self, problem=prob) ## except: ## contestProb = ContestProblem() ## contestProb.contest = self ## contestProb.problem = prob contestProb = ContestProblem() contestProb.contest = self contestProb.problem = prob if not Problem.isLegalTitle(pInfo[1]) or len(pInfo[1]) == 0: contestProb.problem_title = contestProb.problem.prob_title else: contestProb.problem_title = pInfo[1] contestProb.problem_index = pInfo[2] contestProb.save() return True
def addContest( cls, user, courseClass, contestTitle, pInfos, startTime, contestDesc="", length=300, boardStop=300, contestType=0, boardType=0, lang_limit=0, ): # add contest now c = Contest() c.author = user c.course_class = courseClass c.contest_title = contestTitle c._vTitle() c.start_time = startTime c._vStartTime() c.length = length c._vLength() c.board_stop = boardStop c._vBoardStop() c.contest_description = contestDesc c.contest_type = contestType c.board_type = boardType c.lang_limit = lang_limit c.save() # add problem to contest now for pInfo in pInfos: contestProb = ContestProblem() contestProb.contest = c try: contestProb.problem = Problem.objects.get(pid=pInfo[0]) except: raise Exception(Const.CONTEST_PROB_ERR) if not Problem.isLegalTitle(pInfo[1]) or len(pInfo[1]) == 0: contestProb.problem_title = contestProb.problem.prob_title else: contestProb.problem_title = pInfo[1] contestProb.problem_index = pInfo[2] contestProb.save() return c
def addContest(cls, user, courseClass, contestTitle, pInfos, startTime, contestDesc='', length=300, boardStop=300, contestType=0, boardType=0, lang_limit=0): # add contest now c = Contest() c.author = user c.course_class = courseClass c.contest_title = contestTitle c._vTitle() c.start_time = startTime c._vStartTime() c.length = length c._vLength() c.board_stop = boardStop c._vBoardStop() c.contest_description = contestDesc c.contest_type = contestType c.board_type = boardType c.lang_limit = lang_limit c.save() # add problem to contest now for pInfo in pInfos: contestProb = ContestProblem() contestProb.contest = c try: contestProb.problem = Problem.objects.get(pid=pInfo[0]) except: raise Exception(Const.CONTEST_PROB_ERR) if not Problem.isLegalTitle(pInfo[1]) or len(pInfo[1]) == 0: contestProb.problem_title = contestProb.problem.prob_title else: contestProb.problem_title = pInfo[1] contestProb.problem_index = pInfo[2] contestProb.save() return c