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 }}