mirror of
https://gitlab.com/animath/si/plateforme.git
synced 2025-02-24 19:41:18 +00:00
Compare commits
No commits in common. "4ea93d34262f243f231fc748c63baf2b5eb1d038" and "4ea70e5ab93b974a992b6cdd844cbe2ebfd16216" have entirely different histories.
4ea93d3426
...
4ea70e5ab9
@ -447,8 +447,10 @@ class DrawConsumer(AsyncJsonWebsocketConsumer):
|
|||||||
td2.passage_index = current_passage_index
|
td2.passage_index = current_passage_index
|
||||||
if len(round2_pools) == 1 and len(tds) == 5:
|
if len(round2_pools) == 1 and len(tds) == 5:
|
||||||
# Exchange teams 1 and 5 if there is only one pool with 5 teams
|
# Exchange teams 1 and 5 if there is only one pool with 5 teams
|
||||||
if i == 0 or i == 4:
|
if i == 0:
|
||||||
td2.passage_index = 4 - i
|
td2.passage_index = 4
|
||||||
|
elif i == 4:
|
||||||
|
td2.passage_index = 0
|
||||||
current_passage_index += 1
|
current_passage_index += 1
|
||||||
await td2.asave()
|
await td2.asave()
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ class TestDraw(TestCase):
|
|||||||
self.assertFalse(await Draw.objects.filter(tournament=self.tournament).aexists())
|
self.assertFalse(await Draw.objects.filter(tournament=self.tournament).aexists())
|
||||||
|
|
||||||
# Now start the draw
|
# Now start the draw
|
||||||
await communicator.send_json_to({'tid': tid, 'type': 'start_draw', 'fmt': '4+5+3'})
|
await communicator.send_json_to({'tid': tid, 'type': 'start_draw', 'fmt': '3+4+5'})
|
||||||
|
|
||||||
# Receive data after the start
|
# Receive data after the start
|
||||||
self.assertEqual((await communicator.receive_json_from())['type'], 'alert')
|
self.assertEqual((await communicator.receive_json_from())['type'], 'alert')
|
||||||
@ -93,7 +93,7 @@ class TestDraw(TestCase):
|
|||||||
{'tid': tid, 'type': 'dice_visibility', 'visible': True})
|
{'tid': tid, 'type': 'dice_visibility', 'visible': True})
|
||||||
self.assertEqual((await communicator.receive_json_from())['type'], 'alert')
|
self.assertEqual((await communicator.receive_json_from())['type'], 'alert')
|
||||||
self.assertEqual(await communicator.receive_json_from(),
|
self.assertEqual(await communicator.receive_json_from(),
|
||||||
{'tid': tid, 'type': 'draw_start', 'fmt': [3, 4, 5],
|
{'tid': tid, 'type': 'draw_start', 'fmt': [5, 4, 3],
|
||||||
'trigrams': ['AAA', 'BBB', 'CCC', 'DDD', 'EEE', 'FFF',
|
'trigrams': ['AAA', 'BBB', 'CCC', 'DDD', 'EEE', 'FFF',
|
||||||
'GGG', 'HHH', 'III', 'JJJ', 'KKK', 'LLL']})
|
'GGG', 'HHH', 'III', 'JJJ', 'KKK', 'LLL']})
|
||||||
self.assertEqual((await communicator.receive_json_from())['type'], 'set_info')
|
self.assertEqual((await communicator.receive_json_from())['type'], 'set_info')
|
||||||
@ -181,8 +181,8 @@ class TestDraw(TestCase):
|
|||||||
.aget(number=1, draw=draw)
|
.aget(number=1, draw=draw)
|
||||||
p = r.current_pool
|
p = r.current_pool
|
||||||
self.assertEqual(p.letter, 1)
|
self.assertEqual(p.letter, 1)
|
||||||
self.assertEqual(p.size, 3)
|
self.assertEqual(p.size, 5)
|
||||||
self.assertEqual(await p.teamdraw_set.acount(), 3)
|
self.assertEqual(await p.teamdraw_set.acount(), 5)
|
||||||
self.assertEqual(p.current_team, None)
|
self.assertEqual(p.current_team, None)
|
||||||
|
|
||||||
# Render page
|
# Render page
|
||||||
@ -292,7 +292,7 @@ class TestDraw(TestCase):
|
|||||||
self.assertIsNone(td.purposed)
|
self.assertIsNone(td.purposed)
|
||||||
self.assertEqual(td.rejected, [purposed])
|
self.assertEqual(td.rejected, [purposed])
|
||||||
|
|
||||||
for i in range(2):
|
for i in range(4):
|
||||||
# Next team
|
# Next team
|
||||||
p: Pool = await Pool.objects.prefetch_related('current_team__participation__team').aget(round=r, letter=1)
|
p: Pool = await Pool.objects.prefetch_related('current_team__participation__team').aget(round=r, letter=1)
|
||||||
td = p.current_team
|
td = p.current_team
|
||||||
@ -411,6 +411,8 @@ class TestDraw(TestCase):
|
|||||||
td: TeamDraw = await TeamDraw.objects.prefetch_related('participation__team').aget(pk=td.pk)
|
td: TeamDraw = await TeamDraw.objects.prefetch_related('participation__team').aget(pk=td.pk)
|
||||||
self.assertIsNone(td.purposed)
|
self.assertIsNone(td.purposed)
|
||||||
|
|
||||||
|
# Reorder the pool since there are 5 teams
|
||||||
|
self.assertEqual((await communicator.receive_json_from())['type'], 'reorder_poule')
|
||||||
self.assertEqual(await communicator.receive_json_from(),
|
self.assertEqual(await communicator.receive_json_from(),
|
||||||
{'tid': tid, 'type': 'dice_visibility', 'visible': True})
|
{'tid': tid, 'type': 'dice_visibility', 'visible': True})
|
||||||
self.assertEqual((await communicator.receive_json_from())['type'], 'set_info')
|
self.assertEqual((await communicator.receive_json_from())['type'], 'set_info')
|
||||||
@ -508,8 +510,8 @@ class TestDraw(TestCase):
|
|||||||
.aget(number=1, draw=draw)
|
.aget(number=1, draw=draw)
|
||||||
p = r.current_pool
|
p = r.current_pool
|
||||||
self.assertEqual(p.letter, 3)
|
self.assertEqual(p.letter, 3)
|
||||||
self.assertEqual(p.size, 5)
|
self.assertEqual(p.size, 3)
|
||||||
self.assertEqual(await p.teamdraw_set.acount(), 5)
|
self.assertEqual(await p.teamdraw_set.acount(), 3)
|
||||||
self.assertEqual(p.current_team, None)
|
self.assertEqual(p.current_team, None)
|
||||||
self.assertEqual(await communicator.receive_json_from(),
|
self.assertEqual(await communicator.receive_json_from(),
|
||||||
{'tid': tid, 'type': 'set_active', 'round': 1, 'poule': 'C', 'team': None})
|
{'tid': tid, 'type': 'set_active', 'round': 1, 'poule': 'C', 'team': None})
|
||||||
@ -530,7 +532,7 @@ class TestDraw(TestCase):
|
|||||||
|
|
||||||
self.assertEqual((await communicator.receive_json_from())['type'], 'set_info')
|
self.assertEqual((await communicator.receive_json_from())['type'], 'set_info')
|
||||||
|
|
||||||
for i in range(5):
|
for i in range(3):
|
||||||
# Next team
|
# Next team
|
||||||
p: Pool = await Pool.objects.prefetch_related('current_team__participation__team').aget(round=r, letter=3)
|
p: Pool = await Pool.objects.prefetch_related('current_team__participation__team').aget(round=r, letter=3)
|
||||||
td = p.current_team
|
td = p.current_team
|
||||||
@ -560,11 +562,10 @@ class TestDraw(TestCase):
|
|||||||
self.assertIsNotNone(td.purposed)
|
self.assertIsNotNone(td.purposed)
|
||||||
self.assertIn(td.purposed, range(1, len(settings.PROBLEMS) + 1))
|
self.assertIn(td.purposed, range(1, len(settings.PROBLEMS) + 1))
|
||||||
# Lower problems are already accepted
|
# Lower problems are already accepted
|
||||||
self.assertGreaterEqual(td.purposed, 1 + i // 2)
|
self.assertGreaterEqual(td.purposed, i + 1)
|
||||||
|
|
||||||
# Assume that this is the problem is i / 2 for the team i (there are 5 teams)
|
# Assume that this is the problem is i for the team i
|
||||||
# We force to have duplicates
|
td.purposed = i + 1
|
||||||
td.purposed = 1 + i // 2
|
|
||||||
await td.asave()
|
await td.asave()
|
||||||
|
|
||||||
# Render page
|
# Render page
|
||||||
@ -576,11 +577,11 @@ class TestDraw(TestCase):
|
|||||||
self.assertEqual(await communicator.receive_json_from(),
|
self.assertEqual(await communicator.receive_json_from(),
|
||||||
{'tid': tid, 'type': 'buttons_visibility', 'visible': False})
|
{'tid': tid, 'type': 'buttons_visibility', 'visible': False})
|
||||||
self.assertEqual(await communicator.receive_json_from(),
|
self.assertEqual(await communicator.receive_json_from(),
|
||||||
{'tid': tid, 'type': 'set_problem', 'round': 1, 'team': trigram, 'problem': 1 + i // 2})
|
{'tid': tid, 'type': 'set_problem', 'round': 1, 'team': trigram, 'problem': i + 1})
|
||||||
td: TeamDraw = await TeamDraw.objects.prefetch_related('participation__team').aget(pk=td.pk)
|
td: TeamDraw = await TeamDraw.objects.prefetch_related('participation__team').aget(pk=td.pk)
|
||||||
self.assertIsNone(td.purposed)
|
self.assertIsNone(td.purposed)
|
||||||
self.assertEqual(td.accepted, 1 + i // 2)
|
self.assertEqual(td.accepted, i + 1)
|
||||||
if i == 4:
|
if i == 2:
|
||||||
break
|
break
|
||||||
self.assertEqual(await communicator.receive_json_from(),
|
self.assertEqual(await communicator.receive_json_from(),
|
||||||
{'tid': tid, 'type': 'box_visibility', 'visible': True})
|
{'tid': tid, 'type': 'box_visibility', 'visible': True})
|
||||||
@ -590,9 +591,6 @@ class TestDraw(TestCase):
|
|||||||
resp = await self.async_client.get(reverse('draw:index'))
|
resp = await self.async_client.get(reverse('draw:index'))
|
||||||
self.assertEqual(resp.status_code, 200)
|
self.assertEqual(resp.status_code, 200)
|
||||||
|
|
||||||
# Reorder the pool since there are 5 teams
|
|
||||||
self.assertEqual((await communicator.receive_json_from())['type'], 'reorder_poule')
|
|
||||||
|
|
||||||
# Start round 2
|
# Start round 2
|
||||||
draw: Draw = await Draw.objects.prefetch_related(
|
draw: Draw = await Draw.objects.prefetch_related(
|
||||||
'current_round__current_pool__current_team__participation__team').aget(tournament=self.tournament)
|
'current_round__current_pool__current_team__participation__team').aget(tournament=self.tournament)
|
||||||
@ -626,7 +624,7 @@ class TestDraw(TestCase):
|
|||||||
.aget(draw=draw, number=2)
|
.aget(draw=draw, number=2)
|
||||||
p = r.current_pool
|
p = r.current_pool
|
||||||
self.assertEqual(p.letter, i + 1)
|
self.assertEqual(p.letter, i + 1)
|
||||||
self.assertEqual(p.size, i + 3)
|
self.assertEqual(p.size, 5 - i)
|
||||||
|
|
||||||
self.assertEqual(await communicator.receive_json_from(),
|
self.assertEqual(await communicator.receive_json_from(),
|
||||||
{'tid': tid, 'type': 'set_active', 'round': 2, 'poule': chr(65 + i), 'team': None})
|
{'tid': tid, 'type': 'set_active', 'round': 2, 'poule': chr(65 + i), 'team': None})
|
||||||
@ -644,7 +642,7 @@ class TestDraw(TestCase):
|
|||||||
resp = await communicator.receive_json_from()
|
resp = await communicator.receive_json_from()
|
||||||
self.assertEqual(resp['type'], 'set_info')
|
self.assertEqual(resp['type'], 'set_info')
|
||||||
|
|
||||||
for j in range(3 + i):
|
for j in range(5 - i):
|
||||||
# Next team
|
# Next team
|
||||||
p: Pool = await Pool.objects.prefetch_related('current_team__participation__team').aget(round=r,
|
p: Pool = await Pool.objects.prefetch_related('current_team__participation__team').aget(round=r,
|
||||||
letter=i + 1)
|
letter=i + 1)
|
||||||
@ -687,13 +685,13 @@ class TestDraw(TestCase):
|
|||||||
self.assertEqual((await communicator.receive_json_from())['type'], 'set_problem')
|
self.assertEqual((await communicator.receive_json_from())['type'], 'set_problem')
|
||||||
td: TeamDraw = await TeamDraw.objects.prefetch_related('participation__team').aget(pk=td.pk)
|
td: TeamDraw = await TeamDraw.objects.prefetch_related('participation__team').aget(pk=td.pk)
|
||||||
self.assertIsNone(td.purposed)
|
self.assertIsNone(td.purposed)
|
||||||
if j == 2 + i:
|
if j == 4 - i:
|
||||||
break
|
break
|
||||||
self.assertEqual(await communicator.receive_json_from(),
|
self.assertEqual(await communicator.receive_json_from(),
|
||||||
{'tid': tid, 'type': 'box_visibility', 'visible': True})
|
{'tid': tid, 'type': 'box_visibility', 'visible': True})
|
||||||
self.assertEqual((await communicator.receive_json_from())['type'], 'set_info')
|
self.assertEqual((await communicator.receive_json_from())['type'], 'set_info')
|
||||||
|
|
||||||
if i == 2:
|
if i == 0:
|
||||||
# Reorder the pool since there are 5 teams
|
# Reorder the pool since there are 5 teams
|
||||||
self.assertEqual((await communicator.receive_json_from())['type'], 'reorder_poule')
|
self.assertEqual((await communicator.receive_json_from())['type'], 'reorder_poule')
|
||||||
if i < 2:
|
if i < 2:
|
||||||
@ -740,20 +738,20 @@ class TestDraw(TestCase):
|
|||||||
draw = Draw.objects.create(tournament=self.tournament)
|
draw = Draw.objects.create(tournament=self.tournament)
|
||||||
r1 = Round.objects.create(draw=draw, number=1)
|
r1 = Round.objects.create(draw=draw, number=1)
|
||||||
r2 = Round.objects.create(draw=draw, number=2)
|
r2 = Round.objects.create(draw=draw, number=2)
|
||||||
p11 = Pool.objects.create(round=r1, letter=1, size=3)
|
p11 = Pool.objects.create(round=r1, letter=1, size=5)
|
||||||
p12 = Pool.objects.create(round=r1, letter=2, size=4)
|
p12 = Pool.objects.create(round=r1, letter=2, size=4)
|
||||||
p13 = Pool.objects.create(round=r1, letter=3, size=5)
|
p13 = Pool.objects.create(round=r1, letter=3, size=3)
|
||||||
p21 = Pool.objects.create(round=r2, letter=1, size=3)
|
p21 = Pool.objects.create(round=r2, letter=1, size=5)
|
||||||
p22 = Pool.objects.create(round=r2, letter=2, size=4)
|
p22 = Pool.objects.create(round=r2, letter=2, size=4)
|
||||||
p23 = Pool.objects.create(round=r2, letter=3, size=5)
|
p23 = Pool.objects.create(round=r2, letter=3, size=3)
|
||||||
tds = []
|
tds = []
|
||||||
for i, team in enumerate(self.teams):
|
for i, team in enumerate(self.teams):
|
||||||
tds.append(TeamDraw.objects.create(participation=team.participation,
|
tds.append(TeamDraw.objects.create(participation=team.participation,
|
||||||
round=r1,
|
round=r1,
|
||||||
pool=p11 if i < 3 else p12 if i < 7 else p13))
|
pool=p11 if i < 5 else p12 if i < 9 else p13))
|
||||||
tds.append(TeamDraw.objects.create(participation=team.participation,
|
tds.append(TeamDraw.objects.create(participation=team.participation,
|
||||||
round=r2,
|
round=r2,
|
||||||
pool=p21) if i < 3 else p22 if i < 7 else p23)
|
pool=p21) if i < 5 else p22 if i < 9 else p23)
|
||||||
|
|
||||||
p11.current_team = tds[0]
|
p11.current_team = tds[0]
|
||||||
p11.save()
|
p11.save()
|
||||||
|
@ -7,15 +7,17 @@ import re
|
|||||||
from typing import Iterable
|
from typing import Iterable
|
||||||
|
|
||||||
from crispy_forms.helper import FormHelper
|
from crispy_forms.helper import FormHelper
|
||||||
from crispy_forms.layout import Div, Field, Submit
|
from crispy_forms.layout import Div, Submit, Field
|
||||||
from django import forms
|
from django import forms
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
from django.core.exceptions import ValidationError
|
from django.core.exceptions import ValidationError
|
||||||
from django.core.validators import FileExtensionValidator
|
from django.core.validators import FileExtensionValidator
|
||||||
|
from django.db.models import CharField, Value
|
||||||
|
from django.db.models.functions import Concat
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
from pypdf import PdfReader
|
from pypdf import PdfReader
|
||||||
from registration.models import VolunteerRegistration
|
|
||||||
|
|
||||||
|
from registration.models import VolunteerRegistration
|
||||||
from .models import Note, Participation, Passage, Pool, Solution, Synthesis, Team, Tournament
|
from .models import Note, Participation, Passage, Pool, Solution, Synthesis, Team, Tournament
|
||||||
|
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ from django.conf import settings
|
|||||||
from django.core.exceptions import ValidationError
|
from django.core.exceptions import ValidationError
|
||||||
from django.core.validators import MaxValueValidator, MinValueValidator, RegexValidator
|
from django.core.validators import MaxValueValidator, MinValueValidator, RegexValidator
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.db.models import Index
|
from django.db.models import F, Index, Q
|
||||||
from django.urls import reverse_lazy
|
from django.urls import reverse_lazy
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
from django.utils.crypto import get_random_string
|
from django.utils.crypto import get_random_string
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
# Copyright (C) 2020 by Animath
|
# Copyright (C) 2020 by Animath
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
from django.urls import reverse_lazy
|
||||||
from django.utils import formats
|
from django.utils import formats
|
||||||
from django.utils.safestring import mark_safe
|
from django.utils.safestring import mark_safe
|
||||||
from django.utils.text import format_lazy
|
from django.utils.text import format_lazy
|
||||||
|
@ -12,6 +12,7 @@ from zipfile import ZipFile
|
|||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.contrib import messages
|
from django.contrib import messages
|
||||||
from django.contrib.auth.mixins import LoginRequiredMixin
|
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||||
|
from django.contrib.auth.models import User
|
||||||
from django.contrib.sites.models import Site
|
from django.contrib.sites.models import Site
|
||||||
from django.core.exceptions import PermissionDenied
|
from django.core.exceptions import PermissionDenied
|
||||||
from django.core.mail import send_mail
|
from django.core.mail import send_mail
|
||||||
@ -815,6 +816,7 @@ class PoolJuryView(VolunteerMixin, FormView, DetailView):
|
|||||||
form_class = AddJuryForm
|
form_class = AddJuryForm
|
||||||
template_name = 'participation/pool_jury.html'
|
template_name = 'participation/pool_jury.html'
|
||||||
|
|
||||||
|
|
||||||
def dispatch(self, request, *args, **kwargs):
|
def dispatch(self, request, *args, **kwargs):
|
||||||
self.object = self.get_object()
|
self.object = self.get_object()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user