Пример #1
0
 def register_user(self, user_id):
     if self.state == Contest.UNASSIGNED:
         p = Participation(
             contest_id=self.id,
             user_id=user_id,
             skips_left=self.max_skips,
         )
         p.save()
     else:
         raise ContestStartedException(self)
Пример #2
0
 def register_user(self, user_id):
   if self.state == Contest.UNASSIGNED:
     p = Participation(
       contest_id=self.id,
       user_id=user_id,
       skips_left=self.max_skips,
     )
     p.save()
   else:
     raise ContestStartedException(self)
Пример #3
0
 def skip_task(cls, contest_id, user_id, task_id):
   entry = cls.get_entry(contest_id, user_id, task_id)
   p = Participation.get_entry(contest_id, user_id)
   can_skip = p.skips_left > 0 and entry.can_skip()
   if can_skip:
     entry.skipped = True
     entry.save()
     p.skip_task()
     LogEntry.skip_task(contest_id, user_id, task_id)
   else:
     raise IntegrityError
Пример #4
0
 def solve_task(cls, contest_id, user_id, task_id):
   entry = cls.get_entry(contest_id, user_id, task_id)
   if not entry.solved:
     if entry.skipped == True:
       score = cls.SKIPPED
     else:
       score = cls.FULL
     entry.score = score
     entry.solved = True
     entry._try_task()
     p = Participation.get_entry(contest_id, user_id)
     p.increment_score(score)
     LogEntry.solve_task(contest_id, user_id, task_id)
   else:
     raise IntegrityError
Пример #5
0
 def unregister_user(self, user_id):
     if self.state == Contest.UNASSIGNED:
         Participation.get_entry(self.id, user_id).delete()
     else:
         raise ContestStartedException(self)
Пример #6
0
 def unregister_user(self, user_id):
   if self.state == Contest.UNASSIGNED:
     Participation.get_entry(self.id, user_id).delete()
   else:
     raise ContestStartedException(self)