diff --git a/sifrovacka/admin.py b/sifrovacka/admin.py
index 71d191d4..5099c241 100644
--- a/sifrovacka/admin.py
+++ b/sifrovacka/admin.py
@@ -1,8 +1,10 @@
from django.contrib import admin
-from .models import OdpovedUcastnika, SpravnaOdpoved
+from .models import OdpovedUcastnika, SpravnaOdpoved, NapovezenoUcastnikovi, Napoveda
# Register your models here.
admin.site.register(OdpovedUcastnika)
admin.site.register(SpravnaOdpoved)
+admin.site.register(Napoveda)
+admin.site.register(NapovezenoUcastnikovi)
diff --git a/sifrovacka/forms.py b/sifrovacka/forms.py
index e3eba7c7..8a1e16d1 100644
--- a/sifrovacka/forms.py
+++ b/sifrovacka/forms.py
@@ -1,6 +1,6 @@
from django.core.exceptions import ValidationError
from django.forms import ModelForm, Textarea
-from .models import OdpovedUcastnika, SpravnaOdpoved
+from .models import OdpovedUcastnika, SpravnaOdpoved, NapovezenoUcastnikovi, Napoveda
class SifrovackaForm(ModelForm):
@@ -16,3 +16,15 @@ class SifrovackaForm(ModelForm):
if SpravnaOdpoved.objects.filter(sifra=sifra).count() == 0:
raise ValidationError("Tohle číslo šifry v databázi nemáme. Zkontrolujte si ho prosím.")
return sifra
+
+
+class NapovedaForm(ModelForm):
+ class Meta:
+ model = NapovezenoUcastnikovi
+ fields = ["sifra",]
+
+ def clean_sifra(self):
+ sifra = self.cleaned_data.get('sifra')
+ if Napoveda.objects.filter(sifra=sifra).count() == 0:
+ raise ValidationError("K tomuto číslu šifry nemáme nápovědu. Zkonstolujte si ho prosím.")
+ return sifra
diff --git a/sifrovacka/migrations/0004_napoveda_napovezenoucastnikovi.py b/sifrovacka/migrations/0004_napoveda_napovezenoucastnikovi.py
new file mode 100644
index 00000000..cba7ae8f
--- /dev/null
+++ b/sifrovacka/migrations/0004_napoveda_napovezenoucastnikovi.py
@@ -0,0 +1,65 @@
+# Generated by Django 4.2.8 on 2024-04-14 12:57
+
+from django.db import migrations, models
+import django.db.models.deletion
+import django.utils.timezone
+
+
+class Migration(migrations.Migration):
+ dependencies = [
+ (
+ "seminar",
+ "0114_related_name_se_zmenilo_a_django_chce_migraci_tak_dostane_migraci",
+ ),
+ ("sifrovacka", "0003_odpoveducastnika_uspech"),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name="Napoveda",
+ fields=[
+ (
+ "id",
+ models.AutoField(
+ auto_created=True,
+ primary_key=True,
+ serialize=False,
+ verbose_name="ID",
+ ),
+ ),
+ ("text", models.TextField()),
+ ("sifra", models.IntegerField()),
+ ],
+ ),
+ migrations.CreateModel(
+ name="NapovezenoUcastnikovi",
+ fields=[
+ (
+ "id",
+ models.AutoField(
+ auto_created=True,
+ primary_key=True,
+ serialize=False,
+ verbose_name="ID",
+ ),
+ ),
+ ("sifra", models.IntegerField(verbose_name="Číslo šifry")),
+ (
+ "timestamp",
+ models.DateTimeField(
+ default=django.utils.timezone.now, verbose_name="Timestamp"
+ ),
+ ),
+ (
+ "resitel",
+ models.ForeignKey(
+ on_delete=django.db.models.deletion.CASCADE,
+ to="seminar.resitel",
+ ),
+ ),
+ ],
+ options={
+ "ordering": ["-timestamp"],
+ },
+ ),
+ ]
diff --git a/sifrovacka/models.py b/sifrovacka/models.py
index 6517c2e0..beabd0a7 100644
--- a/sifrovacka/models.py
+++ b/sifrovacka/models.py
@@ -25,3 +25,20 @@ class SpravnaOdpoved(models.Model):
def __str__(self):
return f"{self.sifra}: {self.odpoved}"
+
+
+class NapovezenoUcastnikovi(models.Model):
+ class Meta:
+ ordering = ["-timestamp"]
+
+ resitel = models.ForeignKey(Resitel, blank=False, null=False, on_delete=models.CASCADE)
+ sifra = models.IntegerField("Číslo šifry", blank=False, null=False,)
+ timestamp = models.DateTimeField("Timestamp", blank=False, null=False, default=timezone.now)
+
+
+class Napoveda(models.Model):
+ text = models.TextField(blank=False, null=False,)
+ sifra = models.IntegerField(blank=False, null=False,)
+
+ def __str__(self):
+ return f"{self.sifra}: {self.text}"
diff --git a/sifrovacka/templates/sifrovacka/napoveda.html b/sifrovacka/templates/sifrovacka/napoveda.html
new file mode 100644
index 00000000..88944216
--- /dev/null
+++ b/sifrovacka/templates/sifrovacka/napoveda.html
@@ -0,0 +1,48 @@
+{% extends "base.html" %}
+
+{% block content %}
+
+
+
+
Timestamp | +Řešitel | +Šifra | +
---|---|---|
{{ u.timestamp }} | +{{ u.resitel }} | +{{ u.sifra }} | +
{napoveda.text}