Compare commits
No commits in common. "303538bf487fa29a2756a5f4e93be8dc95425653" and "f9ed70d386ca4421d2cb12bbcb5733d085b6049b" have entirely different histories.
303538bf48
...
f9ed70d386
7 changed files with 19 additions and 147 deletions
|
@ -137,33 +137,3 @@ td.c, th.c {
|
||||||
table select {
|
table select {
|
||||||
margin-bottom: 0;
|
margin-bottom: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.podium {
|
|
||||||
> :first-child {
|
|
||||||
font-weight: 900;
|
|
||||||
font-size: 1.25em;
|
|
||||||
&::marker {
|
|
||||||
color: var(--pico-color-amber-200);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
> :nth-child(2) {
|
|
||||||
font-weight: 800;
|
|
||||||
font-size: 1.1em;
|
|
||||||
&::marker {
|
|
||||||
color: var(--pico-color-grey-300);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
> :nth-child(3) {
|
|
||||||
font-weight: 600;
|
|
||||||
font-size: 1.1em;
|
|
||||||
&::marker {
|
|
||||||
color: var(--pico-color-sand-300);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.score {
|
|
||||||
font-weight: 900;
|
|
||||||
color: var(--pico-color-zinc-500);
|
|
||||||
margin-left: .5em;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
16
game/migrations/0020_alter_musikgame_options.py
Normal file
16
game/migrations/0020_alter_musikgame_options.py
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
# Generated by Django 5.2.3 on 2025-06-15 10:59
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
dependencies = [
|
||||||
|
("game", "0019_alter_musikgame_options_musikgame_over"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterModelOptions(
|
||||||
|
name="musikgame",
|
||||||
|
options={"ordering": ["over", "-date"]},
|
||||||
|
),
|
||||||
|
]
|
|
@ -1,55 +0,0 @@
|
||||||
# Generated by Django 5.2.3 on 2025-06-15 11:23
|
|
||||||
|
|
||||||
import django.db.models.deletion
|
|
||||||
from django.conf import settings
|
|
||||||
from django.db import migrations, models
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
dependencies = [
|
|
||||||
("game", "0019_alter_musikgame_options_musikgame_over"),
|
|
||||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.AlterModelOptions(
|
|
||||||
name="musikgame",
|
|
||||||
options={"ordering": ["over", "-date"]},
|
|
||||||
),
|
|
||||||
migrations.CreateModel(
|
|
||||||
name="MusicGameResults",
|
|
||||||
fields=[
|
|
||||||
(
|
|
||||||
"id",
|
|
||||||
models.BigAutoField(
|
|
||||||
auto_created=True,
|
|
||||||
primary_key=True,
|
|
||||||
serialize=False,
|
|
||||||
verbose_name="ID",
|
|
||||||
),
|
|
||||||
),
|
|
||||||
("score", models.PositiveIntegerField(default=0)),
|
|
||||||
(
|
|
||||||
"game",
|
|
||||||
models.ForeignKey(
|
|
||||||
on_delete=django.db.models.deletion.CASCADE, to="game.musikgame"
|
|
||||||
),
|
|
||||||
),
|
|
||||||
(
|
|
||||||
"player",
|
|
||||||
models.ForeignKey(
|
|
||||||
on_delete=django.db.models.deletion.CASCADE,
|
|
||||||
to=settings.AUTH_USER_MODEL,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
options={
|
|
||||||
"ordering": ["-score"],
|
|
||||||
"constraints": [
|
|
||||||
models.UniqueConstraint(
|
|
||||||
fields=("game", "player"), name="unique_result"
|
|
||||||
)
|
|
||||||
],
|
|
||||||
},
|
|
||||||
),
|
|
||||||
]
|
|
|
@ -1,17 +0,0 @@
|
||||||
# Generated by Django 5.2.3 on 2025-06-15 11:33
|
|
||||||
|
|
||||||
from django.db import migrations, models
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
dependencies = [
|
|
||||||
("game", "0020_alter_musikgame_options_musicgameresults"),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.AlterField(
|
|
||||||
model_name="musicgameresults",
|
|
||||||
name="score",
|
|
||||||
field=models.IntegerField(default=0),
|
|
||||||
),
|
|
||||||
]
|
|
|
@ -129,15 +129,3 @@ class MusicGameAnswer(models.Model):
|
||||||
models.UniqueConstraint(fields=("game", "player"), name="unique_answer"),
|
models.UniqueConstraint(fields=("game", "player"), name="unique_answer"),
|
||||||
]
|
]
|
||||||
ordering = ["game"]
|
ordering = ["game"]
|
||||||
|
|
||||||
|
|
||||||
class MusicGameResults(models.Model):
|
|
||||||
game = models.ForeignKey(MusikGame, on_delete=models.CASCADE)
|
|
||||||
player = models.ForeignKey(User, on_delete=models.CASCADE)
|
|
||||||
score = models.IntegerField(default=0)
|
|
||||||
|
|
||||||
class Meta:
|
|
||||||
constraints = [
|
|
||||||
models.UniqueConstraint(fields=("game", "player"), name="unique_result")
|
|
||||||
]
|
|
||||||
ordering = ["-score"]
|
|
||||||
|
|
|
@ -33,17 +33,7 @@
|
||||||
<h2>
|
<h2>
|
||||||
<i class="ri-group-2-fill"></i> Joueurs
|
<i class="ri-group-2-fill"></i> Joueurs
|
||||||
</h2>
|
</h2>
|
||||||
{% if musikgame.over %}
|
<p>{{ musikgame.players.all|join:", " }}</p>
|
||||||
<ol class="podium">
|
|
||||||
{% for player in musikgame.musicgameresults_set.all %}
|
|
||||||
<li>
|
|
||||||
{{ player.player.username }} <span class="score">{{ player.score }}</span>
|
|
||||||
</li>
|
|
||||||
{% endfor %}
|
|
||||||
</ol>
|
|
||||||
{% else %}
|
|
||||||
<p>{{ musikgame.players.all|join:", " }}</p>
|
|
||||||
{% endif %}
|
|
||||||
<h2>
|
<h2>
|
||||||
<i class="ri-music-2-fill"></i> Musiques
|
<i class="ri-music-2-fill"></i> Musiques
|
||||||
</h2>
|
</h2>
|
||||||
|
@ -63,7 +53,7 @@
|
||||||
<h2>
|
<h2>
|
||||||
<i class="ri-list-ordered"></i> Résultats
|
<i class="ri-list-ordered"></i> Résultats
|
||||||
</h2>
|
</h2>
|
||||||
<details open>
|
<details>
|
||||||
<summary role="button">
|
<summary role="button">
|
||||||
<i class="ri-list-ordered-2"></i> Résultats
|
<i class="ri-list-ordered-2"></i> Résultats
|
||||||
</summary>
|
</summary>
|
||||||
|
|
|
@ -9,7 +9,7 @@ from django.contrib.auth.models import User
|
||||||
from django.contrib.messages.views import SuccessMessageMixin
|
from django.contrib.messages.views import SuccessMessageMixin
|
||||||
from django.core.exceptions import PermissionDenied
|
from django.core.exceptions import PermissionDenied
|
||||||
from django.db import IntegrityError
|
from django.db import IntegrityError
|
||||||
from django.db.models import Count, F, Q
|
from django.db.models import Count, Q
|
||||||
from django.shortcuts import get_object_or_404, redirect
|
from django.shortcuts import get_object_or_404, redirect
|
||||||
from django.views import View
|
from django.views import View
|
||||||
from django.views.generic import TemplateView
|
from django.views.generic import TemplateView
|
||||||
|
@ -468,25 +468,5 @@ class GameEndView(LoginRequiredMixin, SingleObjectMixin, View):
|
||||||
if not game.group.is_leader(request.user):
|
if not game.group.is_leader(request.user):
|
||||||
raise PermissionDenied()
|
raise PermissionDenied()
|
||||||
game.over = True
|
game.over = True
|
||||||
|
|
||||||
for player in game.players.all():
|
|
||||||
score = (
|
|
||||||
100
|
|
||||||
* player.musicgameanswer_set.filter(game__game=game)
|
|
||||||
.exclude(game__player=player)
|
|
||||||
.filter(game__player=F("answer"))
|
|
||||||
.count()
|
|
||||||
)
|
|
||||||
score -= (
|
|
||||||
50
|
|
||||||
* player.musicgameanswer_set.filter(game__game=game)
|
|
||||||
.filter(game__player=player)
|
|
||||||
.exclude(game__player=F("answer"))
|
|
||||||
.count()
|
|
||||||
)
|
|
||||||
models.MusicGameResults.objects.create(
|
|
||||||
game=game, player=player, score=score
|
|
||||||
)
|
|
||||||
|
|
||||||
game.save()
|
game.save()
|
||||||
return redirect("game_detail", pk)
|
return redirect("game_detail", pk)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue