2023-03-22 14:49:08 +00:00
|
|
|
# Copyright (C) 2023 by Animath
|
|
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
from django.conf import settings
|
|
|
|
from django.db import models
|
|
|
|
from django.utils.text import format_lazy
|
|
|
|
from django.utils.translation import gettext_lazy as _
|
|
|
|
|
|
|
|
from participation.models import Participation, Tournament
|
|
|
|
|
|
|
|
|
|
|
|
class Draw(models.Model):
|
|
|
|
tournament = models.OneToOneField(
|
|
|
|
Tournament,
|
|
|
|
on_delete=models.CASCADE,
|
|
|
|
verbose_name=_('tournament'),
|
|
|
|
)
|
|
|
|
|
2023-03-22 15:35:59 +00:00
|
|
|
current_round = models.ForeignKey(
|
|
|
|
'Round',
|
|
|
|
on_delete=models.CASCADE,
|
|
|
|
null=True,
|
|
|
|
default=None,
|
|
|
|
related_name='+',
|
|
|
|
verbose_name=_('current round'),
|
|
|
|
)
|
|
|
|
|
2023-03-22 14:49:08 +00:00
|
|
|
class Meta:
|
|
|
|
verbose_name = _('draw')
|
|
|
|
verbose_name_plural = _('draws')
|
|
|
|
|
|
|
|
|
|
|
|
class Round(models.Model):
|
|
|
|
draw = models.ForeignKey(
|
|
|
|
Draw,
|
|
|
|
on_delete=models.CASCADE,
|
|
|
|
verbose_name=_('draw'),
|
|
|
|
)
|
|
|
|
|
|
|
|
number = models.IntegerField(
|
|
|
|
choices=[
|
|
|
|
(1, _('Round 1')),
|
|
|
|
(2, _('Round 2')),
|
|
|
|
],
|
|
|
|
verbose_name=_('number'),
|
|
|
|
)
|
|
|
|
|
2023-03-22 15:35:59 +00:00
|
|
|
current_pool = models.ForeignKey(
|
|
|
|
'Pool',
|
|
|
|
on_delete=models.CASCADE,
|
|
|
|
null=True,
|
|
|
|
default=None,
|
|
|
|
related_name='+',
|
|
|
|
verbose_name=_('current pool'),
|
|
|
|
)
|
|
|
|
|
2023-03-22 14:49:08 +00:00
|
|
|
def __str__(self):
|
|
|
|
return self.get_number_display()
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
verbose_name = _('round')
|
|
|
|
verbose_name_plural = _('rounds')
|
|
|
|
|
|
|
|
|
|
|
|
class Pool(models.Model):
|
|
|
|
round = models.ForeignKey(
|
|
|
|
Round,
|
|
|
|
on_delete=models.CASCADE,
|
|
|
|
)
|
|
|
|
|
|
|
|
letter = models.CharField(
|
|
|
|
max_length=1,
|
|
|
|
choices=[
|
|
|
|
('A', 'A'),
|
|
|
|
('B', 'B'),
|
|
|
|
('C', 'C'),
|
|
|
|
],
|
|
|
|
verbose_name=_('letter'),
|
|
|
|
)
|
|
|
|
|
2023-03-22 15:35:59 +00:00
|
|
|
current_team = models.ForeignKey(
|
|
|
|
'TeamDraw',
|
|
|
|
on_delete=models.CASCADE,
|
|
|
|
null=True,
|
|
|
|
default=None,
|
|
|
|
related_name='+',
|
|
|
|
verbose_name=_('current team'),
|
|
|
|
)
|
|
|
|
|
2023-03-22 14:49:08 +00:00
|
|
|
def __str__(self):
|
|
|
|
return f"{self.letter}{self.round}"
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
verbose_name = _('pool')
|
|
|
|
verbose_name_plural = _('pools')
|
|
|
|
|
|
|
|
|
|
|
|
class TeamDraw(models.Model):
|
|
|
|
participation = models.ForeignKey(
|
|
|
|
Participation,
|
|
|
|
on_delete=models.CASCADE,
|
|
|
|
verbose_name=_('participation'),
|
|
|
|
)
|
|
|
|
|
2023-03-22 15:35:59 +00:00
|
|
|
pool = models.ForeignKey(
|
|
|
|
Pool,
|
|
|
|
on_delete=models.CASCADE,
|
|
|
|
verbose_name=_('pool'),
|
|
|
|
)
|
|
|
|
|
|
|
|
index = models.PositiveSmallIntegerField(
|
|
|
|
choices=zip(range(1, 6), range(1, 6)),
|
|
|
|
verbose_name=_('index'),
|
|
|
|
)
|
|
|
|
|
2023-03-22 14:49:08 +00:00
|
|
|
accepted = models.IntegerField(
|
|
|
|
choices=[
|
|
|
|
(i, format_lazy(_("Problem #{problem}"), problem=i)) for i in range(1, settings.PROBLEM_COUNT + 1)
|
|
|
|
],
|
|
|
|
null=True,
|
|
|
|
default=None,
|
|
|
|
verbose_name=_("accepted problem"),
|
|
|
|
)
|
|
|
|
|
2023-03-22 15:35:59 +00:00
|
|
|
last_dice = models.IntegerField(
|
|
|
|
choices=zip(range(1, 101), range(1, 101)),
|
|
|
|
verbose_name=_("last dice"),
|
|
|
|
)
|
|
|
|
|
2023-03-22 14:49:08 +00:00
|
|
|
purposed = models.IntegerField(
|
|
|
|
choices=[
|
|
|
|
(i, format_lazy(_("Problem #{problem}"), problem=i)) for i in range(1, settings.PROBLEM_COUNT + 1)
|
|
|
|
],
|
|
|
|
null=True,
|
|
|
|
default=None,
|
|
|
|
verbose_name=_("accepted problem"),
|
|
|
|
)
|
|
|
|
|
|
|
|
rejected = models.JSONField(
|
2023-03-22 15:35:59 +00:00
|
|
|
default=list,
|
2023-03-22 14:49:08 +00:00
|
|
|
verbose_name=_('rejected problems'),
|
|
|
|
)
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
verbose_name = _('team draw')
|
|
|
|
verbose_name_plural = _('team draws')
|