From 1f7b770a5c8b71593dead68d3c9beca49243e3ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=C3=A1=C5=A1=20Havelka?= Date: Sun, 15 Oct 2023 19:52:11 +0200 Subject: [PATCH] =?UTF-8?q?Odpov=C4=9Bdi=20od=20=C3=BA=C4=8Dastn=C3=ADk?= =?UTF-8?q?=C5=AF=20maj=C3=AD=20nov=C4=9B=20i=20timestamp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../migrations/0002_auto_20231015_1944.py | 28 +++++++++++++++++++ sifrovacka/models.py | 7 ++++- .../templates/sifrovacka/odpovedi_list.html | 2 ++ 3 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 sifrovacka/migrations/0002_auto_20231015_1944.py diff --git a/sifrovacka/migrations/0002_auto_20231015_1944.py b/sifrovacka/migrations/0002_auto_20231015_1944.py new file mode 100644 index 00000000..dea42891 --- /dev/null +++ b/sifrovacka/migrations/0002_auto_20231015_1944.py @@ -0,0 +1,28 @@ +# Generated by Django 3.2.22 on 2023-10-15 17:44 + +from django.db import migrations, models +import django.utils.timezone + + +class Migration(migrations.Migration): + + dependencies = [ + ('sifrovacka', '0001_initial'), + ] + + operations = [ + migrations.AlterModelOptions( + name='odpoveducastnika', + options={'ordering': ['-timestamp']}, + ), + migrations.AddField( + model_name='odpoveducastnika', + name='timestamp', + field=models.DateTimeField(default=django.utils.timezone.now, verbose_name='Timestamp'), + ), + migrations.AlterField( + model_name='odpoveducastnika', + name='odpoved', + field=models.TextField(verbose_name='Tajenka bez diakritiky'), + ), + ] diff --git a/sifrovacka/models.py b/sifrovacka/models.py index 0e2dc78e..05dd6e4c 100644 --- a/sifrovacka/models.py +++ b/sifrovacka/models.py @@ -1,4 +1,5 @@ from django.db import models +from django.utils import timezone from seminar.models.personalni import Resitel @@ -7,9 +8,13 @@ from seminar.models.personalni import Resitel class OdpovedUcastnika(models.Model): + class Meta: + ordering = ["-timestamp"] + resitel = models.ForeignKey(Resitel, blank=False, null=False, on_delete=models.CASCADE) - odpoved = models.TextField("Tajenka", blank=False, null=False,) + odpoved = models.TextField("Tajenka bez diakritiky", blank=False, null=False,) sifra = models.IntegerField("Číslo šifry", blank=False, null=False,) + timestamp = models.DateTimeField("Timestamp", blank=False, null=False, default=timezone.now) class SpravnaOdpoved(models.Model): diff --git a/sifrovacka/templates/sifrovacka/odpovedi_list.html b/sifrovacka/templates/sifrovacka/odpovedi_list.html index 8e122558..cc52a584 100644 --- a/sifrovacka/templates/sifrovacka/odpovedi_list.html +++ b/sifrovacka/templates/sifrovacka/odpovedi_list.html @@ -6,6 +6,7 @@ + @@ -13,6 +14,7 @@ {% for u in object_list %} +
Timestamp Řešitel Šifra Odpověď
{{ u.timestamp }} {{ u.resitel }} {{ u.sifra }} {{ u.odpoved }}