From 6a5390cdf6463ec2908fa8fa4f965b4f82698d93 Mon Sep 17 00:00:00 2001 From: Pavel 'LEdoian' Turinsky Date: Mon, 11 Dec 2023 20:21:27 +0100 Subject: [PATCH] =?UTF-8?q?P=C5=99id=C3=A1n=C3=AD=20Nastaveni=20do=20vario?= =?UTF-8?q?us?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- various/migrations/0001_initial.py | 26 ++++++++++++++++++++ various/models.py | 38 +++++++++++++++++++++++++++++- 2 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 various/migrations/0001_initial.py diff --git a/various/migrations/0001_initial.py b/various/migrations/0001_initial.py new file mode 100644 index 00000000..5d1232cf --- /dev/null +++ b/various/migrations/0001_initial.py @@ -0,0 +1,26 @@ +# Generated by Django 3.2.23 on 2023-12-11 19:19 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='Nastaveni', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('cena_sous', models.IntegerField(default=1000, verbose_name='Účastnický poplatek za soustředění')), + ], + options={ + 'verbose_name': 'Nastavení semináře', + 'db_table': 'seminar_nastaveni', + 'managed': False, + }, + ), + ] diff --git a/various/models.py b/various/models.py index 71a83623..28a33057 100644 --- a/various/models.py +++ b/various/models.py @@ -1,3 +1,39 @@ from django.db import models -# Create your models here. +from reversion import revisions as reversion +from solo.models import SingletonModel + +from seminar.models import Cislo + +from django.urls import reverse + +@reversion.register(ignore_duplicates=True) +class Nastaveni(SingletonModel): + + class Meta: + db_table = 'seminar_nastaveni' + verbose_name = 'Nastavení semináře' + managed = False + +# aktualni_rocnik = models.ForeignKey(Rocnik, verbose_name='aktuální ročník', +# null=False, on_delete=models.PROTECT) + + aktualni_cislo = models.ForeignKey(Cislo, verbose_name='Aktuální číslo', + null=False, on_delete=models.PROTECT) + + cena_sous = models.IntegerField(null=False, + verbose_name="Účastnický poplatek za soustředění", + default=1000) + + @property + def aktualni_rocnik(self): + return self.aktualni_cislo.rocnik + + def __str__(self): + return 'Nastavení semináře' + + def admin_url(self): + return reverse('admin:seminar_nastaveni_change', args=(self.id, )) + + def verejne(self): + return False