diff --git a/base/static/css/main.css b/base/static/css/main.css index 219394c..80a38b2 100644 --- a/base/static/css/main.css +++ b/base/static/css/main.css @@ -137,3 +137,33 @@ td.c, th.c { table select { 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; + } +} diff --git a/game/migrations/0020_alter_musikgame_options.py b/game/migrations/0020_alter_musikgame_options.py deleted file mode 100644 index cd933d9..0000000 --- a/game/migrations/0020_alter_musikgame_options.py +++ /dev/null @@ -1,16 +0,0 @@ -# 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"]}, - ), - ] diff --git a/game/migrations/0020_alter_musikgame_options_musicgameresults.py b/game/migrations/0020_alter_musikgame_options_musicgameresults.py new file mode 100644 index 0000000..3af5916 --- /dev/null +++ b/game/migrations/0020_alter_musikgame_options_musicgameresults.py @@ -0,0 +1,55 @@ +# 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" + ) + ], + }, + ), + ] diff --git a/game/migrations/0021_alter_musicgameresults_score.py b/game/migrations/0021_alter_musicgameresults_score.py new file mode 100644 index 0000000..3166d4d --- /dev/null +++ b/game/migrations/0021_alter_musicgameresults_score.py @@ -0,0 +1,17 @@ +# 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), + ), + ] diff --git a/game/models.py b/game/models.py index a4e1f91..bf57c6e 100644 --- a/game/models.py +++ b/game/models.py @@ -129,3 +129,15 @@ class MusicGameAnswer(models.Model): models.UniqueConstraint(fields=("game", "player"), name="unique_answer"), ] 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"] diff --git a/game/templates/game/musikgame_detail.html b/game/templates/game/musikgame_detail.html index 0d84cda..5bf75d5 100644 --- a/game/templates/game/musikgame_detail.html +++ b/game/templates/game/musikgame_detail.html @@ -33,7 +33,17 @@
{{ musikgame.players.all|join:", " }}
+ {% if musikgame.over %} +{{ musikgame.players.all|join:", " }}
+ {% endif %}