|
|
@ -40,13 +40,12 @@ class SeminarModelBase(models.Model): |
|
|
|
|
|
|
|
def admin_url(self): |
|
|
|
model_name = self.__class__.__name__.lower() |
|
|
|
return reverse('admin:seminar_%s_change'%(model_name, ), args=(self.id, )) |
|
|
|
return reverse('admin:seminar_{}_change'.format(model_name), args=(self.id, )) |
|
|
|
|
|
|
|
def verejne_url(self): |
|
|
|
return None |
|
|
|
|
|
|
|
@reversion.register(ignore_duplicates=True) |
|
|
|
@python_2_unicode_compatible |
|
|
|
class Osoba(SeminarModelBase): |
|
|
|
|
|
|
|
class Meta: |
|
|
@ -117,14 +116,14 @@ class Osoba(SeminarModelBase): |
|
|
|
options={'quality': 95}) |
|
|
|
|
|
|
|
def plne_jmeno(self): |
|
|
|
return force_unicode('%s %s' % (self.jmeno, self.prijmeni)) |
|
|
|
return '{} {}'.format(self.jmeno, self.prijmeni) |
|
|
|
|
|
|
|
def inicial_krestni(self): |
|
|
|
jmena = self.jmeno.split() |
|
|
|
return " ".join(['{}.'.format(jmeno[0]) for jmeno in jmena]) |
|
|
|
|
|
|
|
def __str__(self): |
|
|
|
return force_unicode("Osoba({})".format(self.plne_jmeno())) |
|
|
|
return self.plne_jmeno() |
|
|
|
|
|
|
|
# |
|
|
|
# Mělo by být částečně vytaženo z Aesopa |
|
|
@ -132,7 +131,6 @@ class Osoba(SeminarModelBase): |
|
|
|
# |
|
|
|
|
|
|
|
@reversion.register(ignore_duplicates=True) |
|
|
|
@python_2_unicode_compatible |
|
|
|
class Skola(SeminarModelBase): |
|
|
|
|
|
|
|
class Meta: |
|
|
@ -185,7 +183,7 @@ class Skola(SeminarModelBase): |
|
|
|
blank=True, null=True) |
|
|
|
|
|
|
|
def __str__(self): |
|
|
|
return force_unicode('%s, %s, %s' % (self.nazev, self.ulice, self.mesto)) |
|
|
|
return '{}, {}, {}'.format(self.nazev, self.ulice, self.mesto) |
|
|
|
|
|
|
|
class Prijemce(SeminarModelBase): |
|
|
|
class Meta: |
|
|
@ -205,9 +203,11 @@ class Prijemce(SeminarModelBase): |
|
|
|
|
|
|
|
# FIXME: možná chceme něco jako vazbu na osobu XOR školu a počet kusů k zaslání |
|
|
|
|
|
|
|
def __str__(self): |
|
|
|
return self.osoba.plne_jmeno() |
|
|
|
|
|
|
|
|
|
|
|
@reversion.register(ignore_duplicates=True) |
|
|
|
@python_2_unicode_compatible |
|
|
|
class Resitel(SeminarModelBase): |
|
|
|
|
|
|
|
class Meta: |
|
|
@ -292,12 +292,11 @@ class Resitel(SeminarModelBase): |
|
|
|
else: |
|
|
|
return 'Akad.' |
|
|
|
def __str__(): |
|
|
|
return(force_unicode(u"Řešitel ({})".format(self.osoba.plne_jmeno()))) |
|
|
|
return self.osoba.plne_jmeno() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@reversion.register(ignore_duplicates=True) |
|
|
|
@python_2_unicode_compatible |
|
|
|
class Rocnik(SeminarModelBase): |
|
|
|
|
|
|
|
class Meta: |
|
|
@ -317,11 +316,11 @@ class Rocnik(SeminarModelBase): |
|
|
|
help_text='Exportuje se jen podle tohoto flagu (ne veřejnosti), a to jen čísla s veřejnou výsledkovkou') |
|
|
|
|
|
|
|
def __str__(self): |
|
|
|
return force_unicode('%s (%d/%d)' % (self.rocnik, self.prvni_rok, self.prvni_rok+1)) |
|
|
|
return '{} ({}/{})'.format(self.rocnik, self.prvni_rok, self.prvni_rok+1) |
|
|
|
|
|
|
|
# Ročník v římských číslech |
|
|
|
def roman(self): |
|
|
|
return force_unicode(roman(int(self.rocnik))) |
|
|
|
return roman(int(self.rocnik)) |
|
|
|
|
|
|
|
def verejne(self): |
|
|
|
return len(self.verejna_cisla()) > 0 |
|
|
@ -367,7 +366,6 @@ def cislo_pdf_filename(self, filename): |
|
|
|
return os.path.join('cislo', 'pdf', rocnik, '{}-{}.pdf'.format(rocnik, self.cislo)) |
|
|
|
|
|
|
|
@reversion.register(ignore_duplicates=True) |
|
|
|
@python_2_unicode_compatible |
|
|
|
class Cislo(SeminarModelBase): |
|
|
|
|
|
|
|
class Meta: |
|
|
@ -418,7 +416,7 @@ class Cislo(SeminarModelBase): |
|
|
|
def __str__(self): |
|
|
|
# Potenciální DB HOG, pokud by se ročník necachoval |
|
|
|
r = Rocnik.cached_rocnik(self.rocnik_id) |
|
|
|
return force_unicode('%s.%s' % (r.rocnik, self.cislo, )) |
|
|
|
return '{}.{}'.format(r.rocnik, self.cislo) |
|
|
|
|
|
|
|
def verejne(self): |
|
|
|
return self.verejne_db |
|
|
@ -428,15 +426,15 @@ class Cislo(SeminarModelBase): |
|
|
|
return reverse('seminar_cislo', kwargs={'rocnik': self.rocnik.rocnik, 'cislo': self.cislo}) |
|
|
|
|
|
|
|
def nasledujici(self): |
|
|
|
u"Vrací None, pokud je toto poslední" |
|
|
|
"Vrací None, pokud je toto poslední" |
|
|
|
return self.relativni_v_rocniku(1) |
|
|
|
|
|
|
|
def predchozi(self): |
|
|
|
u"Vrací None, pokud je toto první" |
|
|
|
"Vrací None, pokud je toto první" |
|
|
|
return self.relativni_v_rocniku(-1) |
|
|
|
|
|
|
|
def relativni_v_rocniku(self, rel_index): |
|
|
|
u"Číslo o `index` dále v ročníku. None pokud neexistuje." |
|
|
|
"Číslo o `index` dále v ročníku. None pokud neexistuje." |
|
|
|
cs = self.rocnik.cisla.order_by('cislo').all() |
|
|
|
i = list(cs).index(self) + rel_index |
|
|
|
if (i < 0) or (i >= len(cs)): |
|
|
@ -453,7 +451,6 @@ class Cislo(SeminarModelBase): |
|
|
|
return c |
|
|
|
|
|
|
|
@reversion.register(ignore_duplicates=True) |
|
|
|
@python_2_unicode_compatible |
|
|
|
class Organizator(SeminarModelBase): |
|
|
|
# zmena dedicnosti z models.Model na SeminarModelBase, potencialni vznik bugu |
|
|
|
|
|
|
@ -486,18 +483,17 @@ class Organizator(SeminarModelBase): |
|
|
|
|
|
|
|
def __str__(self): |
|
|
|
if self.osoba.prezdivka: |
|
|
|
return u"%s '%s' %s".format(self.osoba.jmeno, |
|
|
|
return "{} '{}' {}".format(self.osoba.jmeno, |
|
|
|
self.osoba.prezdivka, |
|
|
|
self.osoba.prijmeni) |
|
|
|
else: |
|
|
|
return u"%s %s".format(self.osoba.jmeno, self.osoba.prijmeni) |
|
|
|
return "{} {}".format(self.osoba.jmeno, self.osoba.prijmeni) |
|
|
|
|
|
|
|
class Meta: |
|
|
|
verbose_name = 'Organizátor' |
|
|
|
verbose_name_plural = 'Organizátoři' |
|
|
|
|
|
|
|
@reversion.register(ignore_duplicates=True) |
|
|
|
@python_2_unicode_compatible |
|
|
|
class Soustredeni(SeminarModelBase): |
|
|
|
|
|
|
|
class Meta: |
|
|
@ -546,7 +542,7 @@ class Soustredeni(SeminarModelBase): |
|
|
|
help_text='Exportuje se jen podle tohoto flagu (ne veřejnosti)') |
|
|
|
|
|
|
|
def __str__(self): |
|
|
|
return force_unicode('%s (%s)'.format(self.misto, self.datum_zacatku)) |
|
|
|
return '{} ({})'.format(self.misto, self.datum_zacatku) |
|
|
|
|
|
|
|
def verejne(self): |
|
|
|
return self.verejne_db |
|
|
@ -559,7 +555,6 @@ class Soustredeni(SeminarModelBase): |
|
|
|
|
|
|
|
|
|
|
|
@reversion.register(ignore_duplicates=True) |
|
|
|
@python_2_unicode_compatible |
|
|
|
class Problem(SeminarModelBase): |
|
|
|
|
|
|
|
class Meta: |
|
|
@ -616,7 +611,7 @@ class Problem(SeminarModelBase): |
|
|
|
|
|
|
|
|
|
|
|
def __str__(self): |
|
|
|
return force_unicode('%s' % (self.nazev, )) |
|
|
|
return self.nazev |
|
|
|
|
|
|
|
# Implicitini implementace, jednotlivé dědící třídy si přepíšou |
|
|
|
def kod_v_rocniku(self): |
|
|
@ -649,7 +644,7 @@ class Problem(SeminarModelBase): |
|
|
|
if self.body: |
|
|
|
b = self.body |
|
|
|
pocet_bodu = int(b) if int(b) == b else b |
|
|
|
return u"({}\u2009b)".format(pocet_bodu) if self.body else "" |
|
|
|
return "({}\u2009b)".format(pocet_bodu) if self.body else "" |
|
|
|
|
|
|
|
class Tema(Problem): |
|
|
|
class Meta: |
|
|
@ -670,8 +665,8 @@ class Tema(Problem): |
|
|
|
def kod_v_rocniku(self): |
|
|
|
if self.stav == 'zadany': |
|
|
|
if self.nadproblem: |
|
|
|
return force_unicode(self.nadproblem.kod_v_rocniku()+".t{}".format(self.kod)) |
|
|
|
return force_unicode("t{}".format(self.kod)) |
|
|
|
return self.nadproblem.kod_v_rocniku()+".t{}".format(self.kod) |
|
|
|
return "t{}".format(self.kod) |
|
|
|
return '<Není zadaný>' |
|
|
|
|
|
|
|
class Clanek(Problem): |
|
|
@ -686,7 +681,7 @@ class Clanek(Problem): |
|
|
|
# Nemělo by být potřeba |
|
|
|
# if self.nadproblem: |
|
|
|
# return force_unicode(self.nadproblem.kod_v_rocniku()+".c{}".format(self.kod)) |
|
|
|
return force_unicode("c{}".format(self.kod)) |
|
|
|
return "c{}".format(self.kod) |
|
|
|
return '<Není zadaný>' |
|
|
|
|
|
|
|
class Text(SeminarModelBase): |
|
|
@ -727,16 +722,15 @@ class Uloha(Problem): |
|
|
|
|
|
|
|
def kod_v_rocniku(self): |
|
|
|
if self.stav == 'zadany': |
|
|
|
name=u"{}.u{}".format(self.cislo_zadani.cislo,self.kod) |
|
|
|
name="{}.u{}".format(self.cislo_zadani.cislo,self.kod) |
|
|
|
if self.nadproblem: |
|
|
|
return force_unicode(self.nadproblem.kod_v_rocniku()+name) |
|
|
|
return force_unicode(name) |
|
|
|
return self.nadproblem.kod_v_rocniku()+name |
|
|
|
return name |
|
|
|
return '<Není zadaný>' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@reversion.register(ignore_duplicates=True) |
|
|
|
@python_2_unicode_compatible |
|
|
|
class Reseni(SeminarModelBase): |
|
|
|
|
|
|
|
class Meta: |
|
|
@ -783,8 +777,7 @@ class Reseni(SeminarModelBase): |
|
|
|
help_text='Udává, zda je řešení zveřejněno') |
|
|
|
|
|
|
|
def __str__(self): |
|
|
|
return force_unicode(u"%s: %s".format(self.resitel.osoba.plne_jmeno(), |
|
|
|
self.problem.nazev)) |
|
|
|
return "{}: {}".format(self.resitel.osoba.plne_jmeno(), self.problem.nazev) |
|
|
|
# NOTE: Potenciální DB HOG (bez select_related) |
|
|
|
|
|
|
|
## Pravdepodobne uz nebude potreba: |
|
|
@ -814,6 +807,9 @@ class Hodnoceni(SeminarModelBase): |
|
|
|
|
|
|
|
problem = models.ForeignKey(Problem, verbose_name='problém') |
|
|
|
|
|
|
|
def __str__(self): |
|
|
|
return "{}, {}, {}".format(self.problem, self.reseni, self.body) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
## FIXME: Budeme řešit později, pokud to bude potřeba. |
|
|
@ -849,7 +845,6 @@ def generate_filename(self, filename): |
|
|
|
|
|
|
|
|
|
|
|
@reversion.register(ignore_duplicates=True) |
|
|
|
@python_2_unicode_compatible |
|
|
|
class PrilohaReseni(SeminarModelBase): |
|
|
|
|
|
|
|
class Meta: |
|
|
@ -871,10 +866,9 @@ class PrilohaReseni(SeminarModelBase): |
|
|
|
help_text='Neveřejná poznámka k příloze řešení (plain text), např. o původu') |
|
|
|
|
|
|
|
def __str__(self): |
|
|
|
return force_unicode(self.soubor) |
|
|
|
return self.soubor |
|
|
|
|
|
|
|
|
|
|
|
@python_2_unicode_compatible |
|
|
|
class Pohadka(SeminarModelBase): |
|
|
|
u"""Kus pohádky před/za úlohou v čísle""" |
|
|
|
|
|
|
@ -917,11 +911,10 @@ class Pohadka(SeminarModelBase): |
|
|
|
|
|
|
|
def __str__(self): |
|
|
|
uryvek = self.text if len(self.text) < 50 else self.text[:(50-3)]+"..." |
|
|
|
return force_unicode(uryvek) |
|
|
|
return uryvek |
|
|
|
|
|
|
|
|
|
|
|
@reversion.register(ignore_duplicates=True) |
|
|
|
@python_2_unicode_compatible |
|
|
|
class Soustredeni_Ucastnici(SeminarModelBase): |
|
|
|
# zmena dedicnosti z models.Model na SeminarModelBase, potencialni vznik bugu |
|
|
|
|
|
|
@ -942,11 +935,10 @@ class Soustredeni_Ucastnici(SeminarModelBase): |
|
|
|
help_text='Neveřejná poznámka k účasti (plain text)') |
|
|
|
|
|
|
|
def __str__(self): |
|
|
|
return force_unicode('%s na %s'.format(self.resitel, self.soustredeni)) |
|
|
|
return '{} na {}'.format(self.resitel, self.soustredeni) |
|
|
|
# NOTE: Poteciální DB HOG bez select_related |
|
|
|
|
|
|
|
@reversion.register(ignore_duplicates=True) |
|
|
|
@python_2_unicode_compatible |
|
|
|
class Soustredeni_Organizatori(SeminarModelBase): |
|
|
|
# zmena dedicnosti z models.Model na SeminarModelBase, potencialni vznik bugu |
|
|
|
|
|
|
@ -967,13 +959,12 @@ class Soustredeni_Organizatori(SeminarModelBase): |
|
|
|
help_text='Neveřejná poznámka k účasti organizátora (plain text)') |
|
|
|
|
|
|
|
def __str__(self): |
|
|
|
return force_unicode('%s na %s'.format(self.organizator, self.soustredeni)) |
|
|
|
return '{} na {}'.format(self.organizator, self.soustredeni) |
|
|
|
# NOTE: Poteciální DB HOG bez select_related |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@reversion.register(ignore_duplicates=True) |
|
|
|
@python_2_unicode_compatible |
|
|
|
class Konfera(models.Model): |
|
|
|
class Meta: |
|
|
|
db_table = 'seminar_konfera' |
|
|
@ -1023,12 +1014,11 @@ class Konfera(models.Model): |
|
|
|
upload_to = generate_filename_konfera, blank=True) |
|
|
|
|
|
|
|
def __str__(self): |
|
|
|
return force_unicode(u"%s: (%s)".format(self.nazev, self.soustredeni)) |
|
|
|
return "{}: ({})".format(self.nazev, self.soustredeni) |
|
|
|
|
|
|
|
|
|
|
|
# Vazebna tabulka. Mozna se generuje automaticky. |
|
|
|
@reversion.register(ignore_duplicates=True) |
|
|
|
@python_2_unicode_compatible |
|
|
|
class Reseni_Resitele(models.Model): |
|
|
|
|
|
|
|
class Meta: |
|
|
@ -1045,11 +1035,10 @@ class Reseni_Resitele(models.Model): |
|
|
|
reseni = models.ForeignKey(Reseni, verbose_name='řešení') |
|
|
|
|
|
|
|
def __str__(self): |
|
|
|
return force_unicode('%s od %s'.format(self.reseni, self.resitel)) |
|
|
|
return '{} od {}'.format(self.reseni, self.resitel) |
|
|
|
# NOTE: Poteciální DB HOG bez select_related |
|
|
|
|
|
|
|
@reversion.register(ignore_duplicates=True) |
|
|
|
@python_2_unicode_compatible |
|
|
|
class Konfery_Ucastnici(models.Model): |
|
|
|
|
|
|
|
class Meta: |
|
|
@ -1069,7 +1058,7 @@ class Konfery_Ucastnici(models.Model): |
|
|
|
help_text='Neveřejná poznámka k účasti (plain text)') |
|
|
|
|
|
|
|
def __str__(self): |
|
|
|
return force_unicode('%s na %s'.format(self.resitel, self.konfera, )) |
|
|
|
return '{} na {}'.format(self.resitel, self.konfera) |
|
|
|
# NOTE: Poteciální DB HOG bez select_related |
|
|
|
|
|
|
|
class Obrazek(SeminarModelBase): |
|
|
@ -1283,6 +1272,12 @@ class Nastaveni(SingletonModel): |
|
|
|
@reversion.register(ignore_duplicates=True) |
|
|
|
@python_2_unicode_compatible |
|
|
|
class Novinky(models.Model): |
|
|
|
|
|
|
|
class Meta: |
|
|
|
verbose_name = 'Novinka' |
|
|
|
verbose_name_plural = 'Novinky' |
|
|
|
ordering = ['-datum'] |
|
|
|
|
|
|
|
datum = models.DateField(auto_now_add=True) |
|
|
|
|
|
|
|
text = models.TextField('Text novinky', blank=True, null=True) |
|
|
@ -1302,9 +1297,3 @@ class Novinky(models.Model): |
|
|
|
|
|
|
|
def __str__(self): |
|
|
|
return '[' + str(self.datum) + '] ' + self.text[0:50] |
|
|
|
|
|
|
|
class Meta: |
|
|
|
verbose_name = 'Novinka' |
|
|
|
verbose_name_plural = 'Novinky' |
|
|
|
ordering = ['-datum'] |
|
|
|
|
|
|
|