Add contest to course

This commit is contained in:
anhkha2003 2024-10-02 14:54:25 -05:00
parent 72eada0a4e
commit f8e9b647c1
22 changed files with 1258 additions and 433 deletions

32
judge/utils/contest.py Normal file
View file

@ -0,0 +1,32 @@
from django.db import transaction
from judge.tasks import rescore_contest
from judge.models import (
Contest,
)
def maybe_trigger_contest_rescore(form, contest):
if any(
f in form.changed_data
for f in (
"start_time",
"end_time",
"time_limit",
"format_config",
"format_name",
"freeze_after",
)
):
transaction.on_commit(rescore_contest.s(contest.key).delay)
if any(
f in form.changed_data
for f in (
"authors",
"curators",
"testers",
)
):
Contest._author_ids.dirty(contest)
Contest._curator_ids.dirty(contest)
Contest._tester_ids.dirty(contest)