diff --git a/draw/consumers.py b/draw/consumers.py index b2815fc..d64c888 100644 --- a/draw/consumers.py +++ b/draw/consumers.py @@ -637,6 +637,7 @@ class DrawConsumer(AsyncJsonWebsocketConsumer): and isinstance(kwargs['problem'], int) and (1 <= kwargs['problem'] <= len(settings.PROBLEMS)): # Admins can force the draw problem = int(kwargs['problem']) + break # Check that the user didn't already accept this problem for the first round # if this is the second round diff --git a/draw/models.py b/draw/models.py index c730b19..9e54e25 100644 --- a/draw/models.py +++ b/draw/models.py @@ -292,7 +292,7 @@ class Pool(models.Model): """ Returns a query set ordered by passage index of all team draws in this pool. """ - return self.teamdraw_set.order_by('passage_index').all() + return self.teamdraw_set.all() @property def trigrams(self) -> list[str]: @@ -545,4 +545,5 @@ class TeamDraw(models.Model): class Meta: verbose_name = _('team draw') verbose_name_plural = _('team draws') - ordering = ('round__draw__tournament__name', 'round__number', 'pool__letter', 'passage_index',) + ordering = ('round__draw__tournament__name', 'round__number', 'pool__letter', 'passage_index', + 'choice_dice', 'passage_dice',) diff --git a/draw/static/draw.js b/draw/static/draw.js index 4a385d5..03e17fc 100644 --- a/draw/static/draw.js +++ b/draw/static/draw.js @@ -40,6 +40,20 @@ function drawDice(tid, trigram = null, result = null) { socket.send(JSON.stringify({'tid': tid, 'type': 'dice', 'trigram': trigram, 'result': result})) } +/** + * Fetch the requested dice from the buttons and request to draw it. + * Only available for debug purposes and for admins. + * @param tid The tournament id + */ +function drawDebugDice(tid) { + let dice_10 = parseInt(document.querySelector(`input[name="debug-dice-${tid}-10"]:checked`).value) + let dice_1 = parseInt(document.querySelector(`input[name="debug-dice-${tid}-1"]:checked`).value) + let result = (dice_10 + dice_1) || 100 + let team_div = document.querySelector(`div[id="dices-${tid}"] > div > div[class*="text-bg-warning"]`) + let team = team_div.getAttribute("data-team") + drawDice(tid, team, result) +} + /** * Request to draw a new problem. * @param tid The tournament id @@ -203,6 +217,14 @@ document.addEventListener('DOMContentLoaded', () => { elem.classList.add('text-bg-success') elem.innerText = `${trigram} 🎲 ${result}` } + + let nextTeam = document.querySelector(` div[id="dices-${tid}"] > div > div[class*="text-bg-warning"]`).getAttribute("data-team") + if (nextTeam) { + // If there is one team that does not have launched its dice, then we update the debug section + let debugSpan = document.getElementById(`debug-dice-${tid}-team`) + if (debugSpan) + debugSpan.innerText = nextTeam + } } /** @@ -212,10 +234,15 @@ document.addEventListener('DOMContentLoaded', () => { */ function updateDiceVisibility(tid, visible) { let div = document.getElementById(`launch-dice-${tid}`) - if (visible) + let div_debug = document.getElementById(`debug-dice-form-${tid}`) + if (visible) { div.classList.remove('d-none') - else + div_debug.classList.remove('d-none') + } + else { div.classList.add('d-none') + div_debug.classList.add('d-none') + } } /** @@ -225,10 +252,15 @@ document.addEventListener('DOMContentLoaded', () => { */ function updateBoxVisibility(tid, visible) { let div = document.getElementById(`draw-problem-${tid}`) - if (visible) + let div_debug = document.getElementById(`debug-problem-form-${tid}`) + if (visible) { div.classList.remove('d-none') - else + div_debug.classList.remove('d-none') + } + else { div.classList.add('d-none') + div_debug.classList.add('d-none') + } } /** @@ -582,6 +614,11 @@ document.addEventListener('DOMContentLoaded', () => { let teamLi = document.getElementById(`recap-${tid}-round-${round}-team-${team}`) if (teamLi !== null) teamLi.classList.add('list-group-item-info') + + let debugSpan = document.getElementById(`debug-problem-${tid}-team`) + if (debugSpan && team) { + debugSpan.innerText = team + } } /** diff --git a/draw/templates/draw/tournament_content.html b/draw/templates/draw/tournament_content.html index 462c331..d0f22d8 100644 --- a/draw/templates/draw/tournament_content.html +++ b/draw/templates/draw/tournament_content.html @@ -37,6 +37,7 @@ {% for td in tournament.draw.current_round.team_draws %}
The solutions draw is ended. You can check the result on votre solution du problème " "{problem}.
" -#: participation/models.py:839 participation/models.py:882 +#: participation/models.py:838 participation/models.py:880 #, python-brace-format msgid "" "You will oppose the solution of the team {opponent} on the problème {problem}. Vous pouvez envoyer votre note " "de synthèse sur cette page.
" -#: participation/models.py:848 participation/models.py:891 +#: participation/models.py:847 participation/models.py:889 #, python-brace-format msgid "" "You will report the solution of the team {reporter} on the problème {problem}. Vous pouvez envoyer votre note " "de synthèse sur cette page.
" -#: participation/models.py:864 registration/models.py:622 +#: participation/models.py:863 registration/models.py:622 msgid "First round" msgstr "Premier tour" -#: participation/models.py:875 +#: participation/models.py:873 #, python-brace-format msgid "" "For the second round, you will defend your "
@@ -934,11 +949,11 @@ msgstr ""
" Pour le second tour, vous défendrez votre "
"solution du problème {problem}. The tournament {tournament} is ended. You can check the results on the Le tournoi {tournament} est terminé. Vous pouvez consulter les résultats "
"sur la page du tournoi.