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