2024-03-30 12:41:46 +00:00
|
|
|
# Copyright (C) 2024 by Animath
|
|
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
|
|
|
from django.core.management import BaseCommand
|
|
|
|
from participation.models import Tournament
|
|
|
|
|
|
|
|
|
|
|
|
class Command(BaseCommand):
|
2024-03-30 15:02:12 +00:00
|
|
|
def add_arguments(self, parser):
|
|
|
|
parser.add_argument(
|
|
|
|
'--tournament', '-t', help="Tournament name to update (if not set, all tournaments will be updated)",
|
|
|
|
)
|
|
|
|
parser.add_argument(
|
|
|
|
'--round', '-r', type=int, help="Round number to update (if not set, all rounds will be updated)",
|
|
|
|
)
|
|
|
|
parser.add_argument(
|
|
|
|
'--letter', '-l', help="Letter of the pool to update (if not set, all pools will be updated)",
|
|
|
|
)
|
|
|
|
|
2024-03-30 12:41:46 +00:00
|
|
|
def handle(self, *args, **options):
|
2024-03-30 15:02:12 +00:00
|
|
|
tournaments = Tournament.objects.all() if not options['tournament'] \
|
|
|
|
else Tournament.objects.filter(name=options['tournament']).all()
|
|
|
|
|
|
|
|
for tournament in tournaments:
|
2024-03-30 12:41:46 +00:00
|
|
|
if options['verbosity'] >= 1:
|
|
|
|
self.stdout.write(f"Updating notation sheet for {tournament}")
|
|
|
|
tournament.create_spreadsheet()
|
2024-03-30 15:02:12 +00:00
|
|
|
|
|
|
|
pools = tournament.pools.all()
|
|
|
|
if options['round']:
|
|
|
|
pools = pools.filter(round=options['round'])
|
|
|
|
if options['letter']:
|
|
|
|
pools = pools.filter(letter=ord(options['letter']) - 64)
|
|
|
|
for pool in pools.all():
|
2024-03-30 12:41:46 +00:00
|
|
|
if options['verbosity'] >= 1:
|
|
|
|
self.stdout.write(f"Updating notation sheet for pool {pool.short_name} for {tournament}")
|
|
|
|
pool.update_spreadsheet()
|