Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove contest_object from submissions whose problem is removed from contest; fixes #2349 #2363

Merged
merged 1 commit into from
Dec 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions judge/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]:
Expand Down Expand Up @@ -79,6 +79,13 @@ def contest_update(sender, instance, **kwargs):
for engine in EFFECTIVE_MATH_ENGINES])


@receiver(post_delete, sender=ContestProblem)
def contest_problem_delete(sender, instance, **kwargs):
# `contest_object` is the `Contest` object indirectly associated with the `Submission` object
# `contest` is the `ContestSubmission` object associated with the `Submission` object
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,)))
Expand Down
Loading