diff --git a/judge/signals.py b/judge/signals.py index ce4c5d4612..ff11d4d40e 100644 --- a/judge/signals.py +++ b/judge/signals.py @@ -9,8 +9,8 @@ from django.dispatch import receiver from .caching import finished_submission -from .models import BlogPost, Comment, Contest, ContestSubmission, EFFECTIVE_MATH_ENGINES, Judge, Language, License, \ - MiscConfig, Organization, Problem, Profile, Submission, WebAuthnCredential +from .models import BlogPost, Comment, Contest, ContestProblem, ContestSubmission, EFFECTIVE_MATH_ENGINES, Judge, \ + Language, License, MiscConfig, Organization, Problem, Profile, Submission, WebAuthnCredential def get_pdf_path(basename: str) -> Optional[str]: @@ -79,6 +79,11 @@ def contest_update(sender, instance, **kwargs): for engine in EFFECTIVE_MATH_ENGINES]) +@receiver(post_delete, sender=ContestProblem) +def contest_problem_delete(sender, instance, **kwargs): + Submission.objects.filter(contest_object=instance.contest, contest__isnull=True).update(contest_object=None) + + @receiver(post_save, sender=License) def license_update(sender, instance, **kwargs): cache.delete(make_template_fragment_key('license_html', (instance.id,)))