|
|
@ -353,7 +353,7 @@ class Rocnik(SeminarModelBase): |
|
|
|
|
|
|
|
def verejna_cisla(self): |
|
|
|
vc = [c for c in self.cisla.all() if c.verejne()] |
|
|
|
vc.sort(key=lambda c: c.cislo) |
|
|
|
vc.sort(key=lambda c: c.poradi) |
|
|
|
return vc |
|
|
|
|
|
|
|
def posledni_verejne_cislo(self): |
|
|
@ -362,7 +362,7 @@ class Rocnik(SeminarModelBase): |
|
|
|
|
|
|
|
def verejne_vysledkovky_cisla(self): |
|
|
|
vc = list(self.cisla.filter(verejna_vysledkovka=True)) |
|
|
|
vc.sort(key=lambda c: c.cislo) |
|
|
|
vc.sort(key=lambda c: c.poradi) |
|
|
|
return vc |
|
|
|
|
|
|
|
def posledni_zverejnena_vysledkovka_cislo(self): |
|
|
@ -387,7 +387,7 @@ class Rocnik(SeminarModelBase): |
|
|
|
|
|
|
|
def cislo_pdf_filename(self, filename): |
|
|
|
rocnik = str(self.rocnik.rocnik) |
|
|
|
return os.path.join('cislo', 'pdf', rocnik, '{}-{}.pdf'.format(rocnik, self.cislo)) |
|
|
|
return os.path.join('cislo', 'pdf', rocnik, '{}-{}.pdf'.format(rocnik, self.poradi)) |
|
|
|
|
|
|
|
@reversion.register(ignore_duplicates=True) |
|
|
|
class Cislo(SeminarModelBase): |
|
|
@ -396,7 +396,7 @@ class Cislo(SeminarModelBase): |
|
|
|
db_table = 'seminar_cisla' |
|
|
|
verbose_name = 'Číslo' |
|
|
|
verbose_name_plural = 'Čísla' |
|
|
|
ordering = ['-rocnik__rocnik', '-cislo'] |
|
|
|
ordering = ['-rocnik__rocnik', '-poradi'] |
|
|
|
|
|
|
|
# Interní ID |
|
|
|
id = models.AutoField(primary_key = True) |
|
|
@ -404,7 +404,7 @@ class Cislo(SeminarModelBase): |
|
|
|
rocnik = models.ForeignKey(Rocnik, verbose_name='ročník', related_name='cisla', |
|
|
|
db_index=True,on_delete=models.PROTECT) |
|
|
|
|
|
|
|
cislo = models.CharField('název čísla', max_length=32, db_index=True, |
|
|
|
poradi = models.CharField('název čísla', max_length=32, db_index=True, |
|
|
|
help_text='Většinou jen "1", vyjímečně "7-8", lexikograficky určuje pořadí v ročníku!') |
|
|
|
|
|
|
|
datum_vydani = models.DateField('datum vydání', blank=True, null=True, |
|
|
@ -437,20 +437,20 @@ class Cislo(SeminarModelBase): |
|
|
|
# CisloNode |
|
|
|
|
|
|
|
def kod(self): |
|
|
|
return '%s.%s' % (self.rocnik.rocnik, self.cislo) |
|
|
|
return '%s.%s' % (self.rocnik.rocnik, self.poradi) |
|
|
|
kod.short_description = 'Kód čísla' |
|
|
|
|
|
|
|
def __str__(self): |
|
|
|
# Potenciální DB HOG, pokud by se ročník necachoval |
|
|
|
r = Rocnik.cached_rocnik(self.rocnik_id) |
|
|
|
return '{}.{}'.format(r.rocnik, self.cislo) |
|
|
|
return '{}.{}'.format(r.rocnik, self.poradi) |
|
|
|
|
|
|
|
def verejne(self): |
|
|
|
return self.verejne_db |
|
|
|
verejne.boolean = True |
|
|
|
|
|
|
|
def verejne_url(self): |
|
|
|
return reverse('seminar_cislo', kwargs={'rocnik': self.rocnik.rocnik, 'cislo': self.cislo}) |
|
|
|
return reverse('seminar_cislo', kwargs={'rocnik': self.rocnik.rocnik, 'cislo': self.poradi}) |
|
|
|
|
|
|
|
def nasledujici(self): |
|
|
|
"Vrací None, pokud je toto poslední" |
|
|
@ -607,7 +607,7 @@ class Problem(SeminarModelBase,PolymorphicModel): |
|
|
|
|
|
|
|
# Problém má podproblémy |
|
|
|
nadproblem = models.ForeignKey('self', verbose_name='nadřazený problém', |
|
|
|
related_name='nadproblem_%(class)s', null=True, blank=True, |
|
|
|
related_name='podproblem', null=True, blank=True, |
|
|
|
on_delete=models.SET_NULL) |
|
|
|
|
|
|
|
STAV_NAVRH = 'navrh' |
|
|
@ -772,7 +772,7 @@ class Uloha(Problem): |
|
|
|
|
|
|
|
def kod_v_rocniku(self): |
|
|
|
if self.stav == 'zadany': |
|
|
|
name="{}.u{}".format(self.cislo_zadani.cislo,self.kod) |
|
|
|
name="{}.u{}".format(self.cislo_zadani.poradi,self.kod) |
|
|
|
if self.nadproblem: |
|
|
|
return self.nadproblem.kod_v_rocniku()+name |
|
|
|
return name |
|
|
@ -1198,7 +1198,7 @@ class CisloNode(TreeNode): |
|
|
|
on_delete = models.PROTECT, # Pokud chci mazat číslo, musím si Node pořešit ručně |
|
|
|
verbose_name = "číslo") |
|
|
|
def __str__(self): |
|
|
|
return 'CisloNode: '+str(self.cislo) |
|
|
|
return 'CisloNode: '+str(self.poradi) |
|
|
|
|
|
|
|
class MezicisloNode(TreeNode): |
|
|
|
class Meta: |
|
|
@ -1319,7 +1319,7 @@ class TextNode(TreeNode): |
|
|
|
# |
|
|
|
# def __str__(self): |
|
|
|
# return "%s: %sb (%s)".format(self.resitel.plne_jmeno(), self.body, |
|
|
|
# str(self.cislo)) |
|
|
|
# str(self.poradi)) |
|
|
|
# # NOTE: DB zatez pri vypisu (ale nepouzivany) |
|
|
|
|
|
|
|
|
|
|
@ -1369,7 +1369,7 @@ class TextNode(TreeNode): |
|
|
|
# |
|
|
|
# def __str__(self): |
|
|
|
# # NOTE: DB HOG (ale nepouzivany) |
|
|
|
# return "%s: %sb / %sb (do %s)" % (self.resitel.plne_jmeno(), self.body, self.body_celkem, str(self.cislo)) |
|
|
|
# return "%s: %sb / %sb (do %s)" % (self.resitel.plne_jmeno(), self.body, self.body_celkem, str(self.poradi)) |
|
|
|
##mozna potreba upravit |
|
|
|
|
|
|
|
|
|
|
|