NDOJ/judge/utils/contest.py

36 lines
892 B
Python
Raw Normal View History

2024-10-02 20:06:33 +00:00
from django.db import transaction
from judge.tasks import rescore_contest
from judge.models import (
Contest,
)
2024-10-03 01:27:49 +00:00
def maybe_trigger_contest_rescore(form, contest, force_rescore=False):
if (
any(
f in form.changed_data
for f in (
"start_time",
"end_time",
"time_limit",
"format_config",
"format_name",
"freeze_after",
)
2024-10-02 20:06:33 +00:00
)
2024-10-03 01:27:49 +00:00
or force_rescore
2024-10-02 20:06:33 +00:00
):
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)