From 05ab90e1d42ff27afaf987bdfc3e8eb20c2973d0 Mon Sep 17 00:00:00 2001 From: cuom1999 Date: Sun, 8 Sep 2024 00:31:24 -0500 Subject: [PATCH] Fix some bugs --- judge/migrations/0091_compiler_message_ansi2html.py | 2 +- judge/signals.py | 11 ++++++++++- requirements.txt | 3 ++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/judge/migrations/0091_compiler_message_ansi2html.py b/judge/migrations/0091_compiler_message_ansi2html.py index 32db431..607ddee 100644 --- a/judge/migrations/0091_compiler_message_ansi2html.py +++ b/judge/migrations/0091_compiler_message_ansi2html.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- import lxml.html as lh from django.db import migrations -from lxml.html.clean import clean_html +from lxml_html_clean import clean_html def strip_error_html(apps, schema_editor): diff --git a/judge/signals.py b/judge/signals.py index cdf66e1..c482c1f 100644 --- a/judge/signals.py +++ b/judge/signals.py @@ -9,6 +9,7 @@ from django.db.models.signals import post_delete, post_save from django.dispatch import receiver import judge +from judge import template_context from judge.utils.problems import finished_submission from .models import ( BlogPost, @@ -25,6 +26,7 @@ from .models import ( Submission, NavigationBar, Solution, + ContestProblem, ) @@ -169,9 +171,16 @@ def contest_submission_update(sender, instance, **kwargs): @receiver(post_save, sender=NavigationBar) def navbar_update(sender, instance, **kwargs): - judge.template_context._nav_bar.dirty() + template_context._nav_bar.dirty() @receiver(post_save, sender=Solution) def solution_update(sender, instance, **kwargs): cache.delete(make_template_fragment_key("solution_content", (instance.id,))) + + +@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) diff --git a/requirements.txt b/requirements.txt index d59cfd6..99b2c0f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -43,4 +43,5 @@ pymdown-extensions mdx-breakless-lists beautifulsoup4 pre-commit -django-ratelimit \ No newline at end of file +django-ratelimit +lxml_html_clean \ No newline at end of file