From 2cd0f0385d9025d4e8b9662af9280e091a450660 Mon Sep 17 00:00:00 2001 From: cuom1999 Date: Sat, 11 Dec 2021 21:27:00 -0600 Subject: [PATCH] Add try except for update contest --- judge/models/profile.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/judge/models/profile.py b/judge/models/profile.py index b6111b7..7e2dc7f 100644 --- a/judge/models/profile.py +++ b/judge/models/profile.py @@ -166,8 +166,12 @@ class Profile(models.Model): remove_contest.alters_data = True def update_contest(self): - contest = self.current_contest - if contest is not None and (contest.ended or not contest.contest.is_accessible_by(self.user)): + from judge.models import ContestParticipation + try: + contest = self.current_contest + if contest is not None and (contest.ended or not contest.contest.is_accessible_by(self.user)): + self.remove_contest() + except ContestParticipation.DoesNotExist: self.remove_contest() update_contest.alters_data = True