diff --git a/api/views/autocomplete.py b/api/views/autocomplete.py index 96b6af71..724f2ced 100644 --- a/api/views/autocomplete.py +++ b/api/views/autocomplete.py @@ -6,7 +6,8 @@ from django.shortcuts import get_object_or_404 from django.db.models import Q from personalni.models import Skola, Resitel -from seminar.models.tvorba import Problem, Nastaveni +from seminar.models.tvorba import Problem +from seminar.models.nastaveni import Nastaveni from .helpers import LoginRequiredAjaxMixin # TODO filosofie - zkratky, jak v databázi, tak ve vyhledávání (SPŠE, GASOŠ, Kpt., soukr) diff --git a/odevzdavatko/forms.py b/odevzdavatko/forms.py index d866e4b6..83e69fbd 100644 --- a/odevzdavatko/forms.py +++ b/odevzdavatko/forms.py @@ -5,7 +5,8 @@ from django.forms.models import inlineformset_factory from django.utils import timezone from personalni.models import Resitel -from seminar.models.tvorba import Problem, Deadline, Nastaveni +from seminar.models.tvorba import Problem, Deadline +from seminar.models.nastaveni import Nastaveni from seminar.models.odevzdavatko import * import logging diff --git a/odevzdavatko/views.py b/odevzdavatko/views.py index 8cfa0e02..82a3dd00 100644 --- a/odevzdavatko/views.py +++ b/odevzdavatko/views.py @@ -17,7 +17,8 @@ from itertools import groupby import logging from seminar.models.odevzdavatko import * -from seminar.models.tvorba import Problem, Nastaveni, Rocnik, Deadline +from seminar.models.tvorba import Problem, Rocnik, Deadline +from seminar.models.nastaveni import Nastaveni from personalni.models import Resitel, Organizator, Osoba from . import forms as f from .forms import OdevzdavatkoTabulkaFiltrForm as FiltrForm diff --git a/personalni/views.py b/personalni/views.py index 43c081b7..6720dd7c 100644 --- a/personalni/views.py +++ b/personalni/views.py @@ -11,7 +11,8 @@ from django.http import HttpResponse from seminar.models.odevzdavatko import Hodnoceni from .models import * -from seminar.models.tvorba import Tema, Uloha, Clanek, Nastaveni +from seminar.models.tvorba import Tema, Uloha, Clanek +from seminar.models.nastaveni import Nastaveni from seminar.models.soustredeni import Soustredeni from .forms import PrihlaskaForm, ProfileEditForm, PoMaturiteProfileEditForm diff --git a/seminar/admin.py b/seminar/admin.py index b0301bf3..d078eace 100644 --- a/seminar/admin.py +++ b/seminar/admin.py @@ -9,7 +9,8 @@ from django.utils.safestring import mark_safe # Todo: reversion -from seminar.models.tvorba import Rocnik, Cislo, Deadline, ZmrazenaVysledkovka, Problem, Uloha, Tema, Clanek, Nastaveni +from seminar.models.tvorba import Rocnik, Cislo, Deadline, ZmrazenaVysledkovka, Problem, Uloha, Tema, Clanek +from seminar.models.nastaveni import Nastaveni from personalni.models import Resitel from seminar.models.soustredeni import Konfera from seminar.models.novinky import Novinky diff --git a/seminar/models/nastaveni.py b/seminar/models/nastaveni.py new file mode 100644 index 00000000..abfb4f4b --- /dev/null +++ b/seminar/models/nastaveni.py @@ -0,0 +1,37 @@ +from django.db import models +from django.urls import reverse +from reversion import revisions as reversion +from solo.models import SingletonModel + +from seminar.models.tvorba import Cislo + + +@reversion.register(ignore_duplicates=True) +class Nastaveni(SingletonModel): + + class Meta: + db_table = 'seminar_nastaveni' + verbose_name = 'Nastavení semináře' + +# 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 diff --git a/seminar/models/tvorba.py b/seminar/models/tvorba.py index 93944e99..c825b4f5 100644 --- a/seminar/models/tvorba.py +++ b/seminar/models/tvorba.py @@ -724,34 +724,3 @@ class Pohadka(SeminarModelBase): except ObjectDoesNotExist: # Neexistující *Node nemá smysl aktualizovat. pass - - -@reversion.register(ignore_duplicates=True) -class Nastaveni(SingletonModel): - - class Meta: - db_table = 'seminar_nastaveni' - verbose_name = 'Nastavení semináře' - -# 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 diff --git a/seminar/testutils.py b/seminar/testutils.py index 0248e694..354db259 100644 --- a/seminar/testutils.py +++ b/seminar/testutils.py @@ -12,6 +12,7 @@ import unidecode import logging from korektury.testutils import create_test_pdf +from models.nastaveni import * from personalni.models import * from seminar.models.tvorba import * from seminar.models.odevzdavatko import * diff --git a/seminar/views/views_all.py b/seminar/views/views_all.py index b77a5e44..e1de4829 100644 --- a/seminar/views/views_all.py +++ b/seminar/views/views_all.py @@ -9,7 +9,8 @@ from django.db.models import Q, Sum, Count from django.views.generic.base import RedirectView from django.core.exceptions import PermissionDenied -from seminar.models.tvorba import Rocnik, Cislo, Nastaveni, Deadline, Problem, Tema, Clanek +from seminar.models.tvorba import Rocnik, Cislo, Deadline, Problem, Tema, Clanek +from seminar.models.nastaveni import Nastaveni from personalni.models import Resitel, Organizator from seminar.models.novinky import Novinky #from .models import VysledkyZaCislo, VysledkyKCisluZaRocnik, VysledkyKCisluOdjakziva diff --git a/soustredeni/views.py b/soustredeni/views.py index 1dbc23ed..47ddde35 100644 --- a/soustredeni/views.py +++ b/soustredeni/views.py @@ -5,7 +5,7 @@ from django.conf import settings from django.contrib.staticfiles.finders import find from seminar.models.soustredeni import * from personalni.models import Resitel -from seminar.models.tvorba import Nastaveni +from seminar.models.nastaveni import Nastaveni import csv import tempfile import shutil