Merge branch 'data_migrations' of gimli.ms.mff.cuni.cz:/akce/mam/git/mamweb into data_migrations
This commit is contained in:
commit
a880cbc67b
8 changed files with 263 additions and 1629 deletions
107
seminar/migrations/0068_treenode_nazev.py
Normal file
107
seminar/migrations/0068_treenode_nazev.py
Normal file
|
@ -0,0 +1,107 @@
|
||||||
|
# Generated by Django 2.2.5 on 2019-09-26 19:35
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
# Migrace nejspíš neumí volat metody modelů:
|
||||||
|
# https://stackoverflow.com/questions/28777338/django-migrations-runpython-not-able-to-call-model-methods#37685925
|
||||||
|
|
||||||
|
def fix_RocnikNode_names(apps,schema_editor):
|
||||||
|
Objects = apps.get_model('seminar', 'RocnikNode')
|
||||||
|
for obj in Objects.objects.all():
|
||||||
|
obj.nazev = str(obj.rocnik)+" (RocnikNode)"
|
||||||
|
obj.save()
|
||||||
|
|
||||||
|
def fix_CisloNode_names(apps,schema_editor):
|
||||||
|
Objects = apps.get_model('seminar', 'CisloNode')
|
||||||
|
for obj in Objects.objects.all():
|
||||||
|
obj.nazev = str(obj.cislo)+" (CisloNode)"
|
||||||
|
obj.save()
|
||||||
|
|
||||||
|
def fix_MezicisloNode_names(apps,schema_editor):
|
||||||
|
Objects = apps.get_model('seminar', 'MezicisloNode')
|
||||||
|
for obj in Objects.objects.all():
|
||||||
|
if obj.prev:
|
||||||
|
if (obj.prev.get_real_instance_class() != CisloNode and
|
||||||
|
obj.prev.get_real_instance_class() != MezicisloNode):
|
||||||
|
raise ValueError("Předchůdce není číslo!")
|
||||||
|
posledni = obj.prev.cislo
|
||||||
|
obj.nazev = "Mezičíslo po čísle"+str(posledni)+" (MezicisloNode)"
|
||||||
|
elif obj.root:
|
||||||
|
if obj.root.get_real_instance_class() != RocnikNode:
|
||||||
|
raise ValueError("Kořen stromu není ročník!")
|
||||||
|
rocnik = obj.root.rocnik
|
||||||
|
obj.nazev = "První mezičíslo ročníku "+" (MezicisloNode)"
|
||||||
|
else:
|
||||||
|
print("!!!!! Nějaké neidentifikované mezičíslo !!!!!")
|
||||||
|
obj.nazev = "Neidentifikovatelné mezičíslo! (MezicisloNode)"
|
||||||
|
obj.save()
|
||||||
|
|
||||||
|
def fix_TemaVCisleNode_names(apps,schema_editor):
|
||||||
|
Objects = apps.get_model('seminar', 'TemaVCisleNode')
|
||||||
|
for obj in Objects.objects.all():
|
||||||
|
obj.nazev = str(obj.tema)+" (TemaVCisleNode)"
|
||||||
|
obj.save()
|
||||||
|
|
||||||
|
def fix_KonferaNode_names(apps,schema_editor):
|
||||||
|
Objects = apps.get_model('seminar', 'KonferaNode')
|
||||||
|
for obj in Objects.objects.all():
|
||||||
|
obj.nazev = str(obj.konfera)+" (KonferaNode)"
|
||||||
|
obj.save()
|
||||||
|
|
||||||
|
def fix_ClanekNode_names(apps,schema_editor):
|
||||||
|
Objects = apps.get_model('seminar', 'ClanekNode')
|
||||||
|
for obj in Objects.objects.all():
|
||||||
|
obj.nazev = str(obj.clanek)+" (ClanekNode)"
|
||||||
|
obj.save()
|
||||||
|
|
||||||
|
def fix_UlohaZadaniNode_names(apps,schema_editor):
|
||||||
|
Objects = apps.get_model('seminar', 'UlohaZadaniNode')
|
||||||
|
for obj in Objects.objects.all():
|
||||||
|
obj.nazev = str(obj.uloha)+" (UlohaZadaniNode)"
|
||||||
|
obj.save()
|
||||||
|
|
||||||
|
def fix_PohadkaNode_names(apps,schema_editor):
|
||||||
|
Objects = apps.get_model('seminar', 'PohadkaNode')
|
||||||
|
for obj in Objects.objects.all():
|
||||||
|
obj.nazev = str(obj.pohadka)+" (PohadkaNode)"
|
||||||
|
obj.save()
|
||||||
|
|
||||||
|
def fix_UlohaVzorakNode_names(apps,schema_editor):
|
||||||
|
Objects = apps.get_model('seminar', 'UlohaVzorakNode')
|
||||||
|
for obj in Objects.objects.all():
|
||||||
|
obj.nazev = str(obj.uloha)+" (UlohaVzorakNode)"
|
||||||
|
obj.save()
|
||||||
|
|
||||||
|
def fix_TextNode_names(apps,schema_editor):
|
||||||
|
Objects = apps.get_model('seminar', 'TextNode')
|
||||||
|
for obj in Objects.objects.all():
|
||||||
|
obj.nazev = str(obj.text)+" (TextNode)"
|
||||||
|
obj.save()
|
||||||
|
|
||||||
|
def fix_all_names(apps,schema_editor):
|
||||||
|
fix_RocnikNode_names(apps,schema_editor)
|
||||||
|
fix_CisloNode_names(apps,schema_editor)
|
||||||
|
fix_MezicisloNode_names(apps,schema_editor)
|
||||||
|
fix_TemaVCisleNode_names(apps,schema_editor)
|
||||||
|
fix_KonferaNode_names(apps,schema_editor)
|
||||||
|
fix_ClanekNode_names(apps,schema_editor)
|
||||||
|
fix_UlohaZadaniNode_names(apps,schema_editor)
|
||||||
|
fix_PohadkaNode_names(apps,schema_editor)
|
||||||
|
fix_UlohaVzorakNode_names(apps,schema_editor)
|
||||||
|
fix_TextNode_names(apps,schema_editor)
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('seminar', '0067_auto_20190814_0805'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='treenode',
|
||||||
|
name='nazev',
|
||||||
|
field=models.TextField(help_text='Tento název se zobrazuje v nabídkách pro výběr vhodného TreeNode', null=True, verbose_name='název tohoto node'),
|
||||||
|
),
|
||||||
|
migrations.RunPython(fix_all_names),
|
||||||
|
]
|
28
seminar/migrations/0069_auto_20191120_2115.py
Normal file
28
seminar/migrations/0069_auto_20191120_2115.py
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
# Generated by Django 2.2.7 on 2019-11-20 20:15
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('seminar', '0068_treenode_nazev'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterModelOptions(
|
||||||
|
name='cislo',
|
||||||
|
options={'ordering': ['-rocnik__rocnik', '-poradi'], 'verbose_name': 'Číslo', 'verbose_name_plural': 'Čísla'},
|
||||||
|
),
|
||||||
|
migrations.RenameField(
|
||||||
|
model_name='cislo',
|
||||||
|
old_name='cislo',
|
||||||
|
new_name='poradi',
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='problem',
|
||||||
|
name='nadproblem',
|
||||||
|
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='podproblem', to='seminar.Problem', verbose_name='nadřazený problém'),
|
||||||
|
),
|
||||||
|
]
|
|
@ -384,6 +384,14 @@ class Rocnik(SeminarModelBase):
|
||||||
cache.set(name, c, 300)
|
cache.set(name, c, 300)
|
||||||
return c
|
return c
|
||||||
|
|
||||||
|
def save(self, *args, **kwargs):
|
||||||
|
super().save(*args, **kwargs)
|
||||||
|
# *Node.save() aktualizuje název *Nodu.
|
||||||
|
try:
|
||||||
|
self.rocniknode.save()
|
||||||
|
except ObjectDoesNotExist:
|
||||||
|
# Neexistující *Node nemá smysl aktualizovat.
|
||||||
|
pass
|
||||||
|
|
||||||
def cislo_pdf_filename(self, filename):
|
def cislo_pdf_filename(self, filename):
|
||||||
rocnik = str(self.rocnik.rocnik)
|
rocnik = str(self.rocnik.rocnik)
|
||||||
|
@ -472,11 +480,20 @@ class Cislo(SeminarModelBase):
|
||||||
def get(cls, rocnik, cislo):
|
def get(cls, rocnik, cislo):
|
||||||
try:
|
try:
|
||||||
r = Rocnik.objects.get(rocnik=rocnik)
|
r = Rocnik.objects.get(rocnik=rocnik)
|
||||||
c = r.cisla.get(cislo=cislo)
|
c = r.cisla.get(poradi=cislo)
|
||||||
except ObjectDoesNotExist:
|
except ObjectDoesNotExist:
|
||||||
return None
|
return None
|
||||||
return c
|
return c
|
||||||
|
|
||||||
|
def save(self, *args, **kwargs):
|
||||||
|
super().save(*args, **kwargs)
|
||||||
|
# *Node.save() aktualizuje název *Nodu.
|
||||||
|
try:
|
||||||
|
self.cislonode.save()
|
||||||
|
except ObjectDoesNotExist:
|
||||||
|
# Neexistující *Node nemá smysl aktualizovat.
|
||||||
|
pass
|
||||||
|
|
||||||
@reversion.register(ignore_duplicates=True)
|
@reversion.register(ignore_duplicates=True)
|
||||||
class Organizator(SeminarModelBase):
|
class Organizator(SeminarModelBase):
|
||||||
# zmena dedicnosti z models.Model na SeminarModelBase, potencialni vznik bugu
|
# zmena dedicnosti z models.Model na SeminarModelBase, potencialni vznik bugu
|
||||||
|
@ -707,6 +724,12 @@ class Tema(Problem):
|
||||||
return "t{}".format(self.kod)
|
return "t{}".format(self.kod)
|
||||||
return '<Není zadaný>'
|
return '<Není zadaný>'
|
||||||
|
|
||||||
|
def save(self, *args, **kwargs):
|
||||||
|
super().save(*args, **kwargs)
|
||||||
|
# *Node.save() aktualizuje název *Nodu.
|
||||||
|
for tvcn in self.temavcislenode_set.all():
|
||||||
|
tvcn.save()
|
||||||
|
|
||||||
class Clanek(Problem):
|
class Clanek(Problem):
|
||||||
class Meta:
|
class Meta:
|
||||||
db_table = 'seminar_clanky'
|
db_table = 'seminar_clanky'
|
||||||
|
@ -727,6 +750,15 @@ class Clanek(Problem):
|
||||||
return "c{}".format(self.kod)
|
return "c{}".format(self.kod)
|
||||||
return '<Není zadaný>'
|
return '<Není zadaný>'
|
||||||
|
|
||||||
|
def save(self, *args, **kwargs):
|
||||||
|
super().save(*args, **kwargs)
|
||||||
|
# *Node.save() aktualizuje název *Nodu.
|
||||||
|
try:
|
||||||
|
self.claneknode.save()
|
||||||
|
except ObjectDoesNotExist:
|
||||||
|
# Neexistující *Node nemá smysl aktualizovat.
|
||||||
|
pass
|
||||||
|
|
||||||
class Text(SeminarModelBase):
|
class Text(SeminarModelBase):
|
||||||
class Meta:
|
class Meta:
|
||||||
db_table = 'seminar_texty'
|
db_table = 'seminar_texty'
|
||||||
|
@ -744,6 +776,12 @@ class Text(SeminarModelBase):
|
||||||
|
|
||||||
# obrázky mají návaznost opačným směrem (vazba z druhé strany)
|
# obrázky mají návaznost opačným směrem (vazba z druhé strany)
|
||||||
|
|
||||||
|
def save(self, *args, **kwargs):
|
||||||
|
super().save(*args, **kwargs)
|
||||||
|
# *Node.save() aktualizuje název *Nodu.
|
||||||
|
for tn in self.textnode_set.all():
|
||||||
|
tn.save()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Uloha(Problem):
|
class Uloha(Problem):
|
||||||
|
@ -778,6 +816,20 @@ class Uloha(Problem):
|
||||||
return name
|
return name
|
||||||
return '<Není zadaný>'
|
return '<Není zadaný>'
|
||||||
|
|
||||||
|
def save(self, *args, **kwargs):
|
||||||
|
super().save(*args, **kwargs)
|
||||||
|
# *Node.save() aktualizuje název *Nodu.
|
||||||
|
try:
|
||||||
|
self.ulohazadaninode.save()
|
||||||
|
except ObjectDoesNotExist:
|
||||||
|
# Neexistující *Node nemá smysl aktualizovat.
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
self.ulohavzoraknode.save()
|
||||||
|
except ObjectDoesNotExist:
|
||||||
|
# Neexistující *Node nemá smysl aktualizovat.
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
@reversion.register(ignore_duplicates=True)
|
@reversion.register(ignore_duplicates=True)
|
||||||
class Reseni(SeminarModelBase):
|
class Reseni(SeminarModelBase):
|
||||||
|
@ -959,6 +1011,14 @@ class Pohadka(SeminarModelBase):
|
||||||
uryvek = self.text if len(self.text) < 50 else self.text[:(50-3)]+"..."
|
uryvek = self.text if len(self.text) < 50 else self.text[:(50-3)]+"..."
|
||||||
return uryvek
|
return uryvek
|
||||||
|
|
||||||
|
def save(self, *args, **kwargs):
|
||||||
|
super().save(*args, **kwargs)
|
||||||
|
# *Node.save() aktualizuje název *Nodu.
|
||||||
|
try:
|
||||||
|
self.pohadkanode.save()
|
||||||
|
except ObjectDoesNotExist:
|
||||||
|
# Neexistující *Node nemá smysl aktualizovat.
|
||||||
|
pass
|
||||||
|
|
||||||
@reversion.register(ignore_duplicates=True)
|
@reversion.register(ignore_duplicates=True)
|
||||||
class Soustredeni_Ucastnici(SeminarModelBase):
|
class Soustredeni_Ucastnici(SeminarModelBase):
|
||||||
|
@ -1069,6 +1129,15 @@ class Konfera(models.Model):
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "{}: ({})".format(self.nazev, self.soustredeni)
|
return "{}: ({})".format(self.nazev, self.soustredeni)
|
||||||
|
|
||||||
|
def save(self, *args, **kwargs):
|
||||||
|
super().save(*args, **kwargs)
|
||||||
|
# *Node.save() aktualizuje název *Nodu.
|
||||||
|
try:
|
||||||
|
self.konferanode.save()
|
||||||
|
except ObjectDoesNotExist:
|
||||||
|
# Neexistující *Node nemá smysl aktualizovat.
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
# Vazebna tabulka. Mozna se generuje automaticky.
|
# Vazebna tabulka. Mozna se generuje automaticky.
|
||||||
@reversion.register(ignore_duplicates=True)
|
@reversion.register(ignore_duplicates=True)
|
||||||
|
@ -1147,6 +1216,7 @@ class TreeNode(PolymorphicModel):
|
||||||
verbose_name = "TreeNode"
|
verbose_name = "TreeNode"
|
||||||
verbose_name_plural = "TreeNody"
|
verbose_name_plural = "TreeNody"
|
||||||
|
|
||||||
|
# TODO: Nechceme radši jako root vyžadovat přímo RocnikNode?
|
||||||
root = models.ForeignKey('TreeNode',
|
root = models.ForeignKey('TreeNode',
|
||||||
related_name="potomci_set",
|
related_name="potomci_set",
|
||||||
null = True,
|
null = True,
|
||||||
|
@ -1176,7 +1246,15 @@ class TreeNode(PolymorphicModel):
|
||||||
self.succ.print_tree(indent=indent)
|
self.succ.print_tree(indent=indent)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.nazev
|
if self.nazev:
|
||||||
|
return self.nazev
|
||||||
|
else:
|
||||||
|
#TODO: logování
|
||||||
|
return "Nepojmenovaný Treenode"
|
||||||
|
|
||||||
|
def save(self, *args, **kwargs):
|
||||||
|
self.aktualizuj_nazev()
|
||||||
|
super().save(*args, **kwargs)
|
||||||
|
|
||||||
class RocnikNode(TreeNode):
|
class RocnikNode(TreeNode):
|
||||||
class Meta:
|
class Meta:
|
||||||
|
@ -1186,8 +1264,9 @@ class RocnikNode(TreeNode):
|
||||||
rocnik = models.OneToOneField(Rocnik,
|
rocnik = models.OneToOneField(Rocnik,
|
||||||
on_delete = models.PROTECT, # Pokud chci mazat ročník, musím si Node pořešit ručně
|
on_delete = models.PROTECT, # Pokud chci mazat ročník, musím si Node pořešit ručně
|
||||||
verbose_name = "ročník")
|
verbose_name = "ročník")
|
||||||
def __str__(self):
|
|
||||||
return 'RocnikNode: '+str(self.rocnik)
|
def aktualizuj_nazev(self):
|
||||||
|
self.nazev = "RocnikNode: "+str(self.rocnik)
|
||||||
|
|
||||||
class CisloNode(TreeNode):
|
class CisloNode(TreeNode):
|
||||||
class Meta:
|
class Meta:
|
||||||
|
@ -1197,16 +1276,31 @@ class CisloNode(TreeNode):
|
||||||
cislo = models.OneToOneField(Cislo,
|
cislo = models.OneToOneField(Cislo,
|
||||||
on_delete = models.PROTECT, # Pokud chci mazat číslo, musím si Node pořešit ručně
|
on_delete = models.PROTECT, # Pokud chci mazat číslo, musím si Node pořešit ručně
|
||||||
verbose_name = "číslo")
|
verbose_name = "číslo")
|
||||||
def __str__(self):
|
|
||||||
return 'CisloNode: '+str(self.poradi)
|
def aktualizuj_nazev(self):
|
||||||
|
self.nazev = "CisloNode: "+str(self.cislo)
|
||||||
|
|
||||||
class MezicisloNode(TreeNode):
|
class MezicisloNode(TreeNode):
|
||||||
class Meta:
|
class Meta:
|
||||||
db_table = 'seminar_nodes_mezicislo'
|
db_table = 'seminar_nodes_mezicislo'
|
||||||
verbose_name = 'Mezičíslo (Node)'
|
verbose_name = 'Mezičíslo (Node)'
|
||||||
verbose_name_plural = 'Mezičísla (Node)'
|
verbose_name_plural = 'Mezičísla (Node)'
|
||||||
def __str__(self):
|
|
||||||
return 'MezicisloNode'
|
def aktualizuj_nazev(self):
|
||||||
|
if self.prev:
|
||||||
|
if (self.prev.get_real_instance_class() != CisloNode and
|
||||||
|
self.prev.get_real_instance_class() != MezicisloNode):
|
||||||
|
raise ValueError("Předchůdce není číslo!")
|
||||||
|
posledni = self.prev.cislo
|
||||||
|
self.nazev = "MezicisloNode: Mezičíslo po čísle"+str(posledni)
|
||||||
|
elif self.root:
|
||||||
|
if self.root.get_real_instance_class() != RocnikNode:
|
||||||
|
raise ValueError("Kořen stromu není ročník!")
|
||||||
|
rocnik = self.root.rocnik
|
||||||
|
self.nazev = "MezicisloNode: První mezičíslo ročníku "+str(rocnik)
|
||||||
|
else:
|
||||||
|
print("!!!!! Nějaké neidentifikované mezičíslo !!!!!")
|
||||||
|
self.nazev = "MezicisloNode: Neidentifikovatelné mezičíslo!"
|
||||||
|
|
||||||
class TemaVCisleNode(TreeNode):
|
class TemaVCisleNode(TreeNode):
|
||||||
""" Obsahuje příspěvky k tématu v daném čísle """
|
""" Obsahuje příspěvky k tématu v daném čísle """
|
||||||
|
@ -1217,8 +1311,9 @@ class TemaVCisleNode(TreeNode):
|
||||||
tema = models.ForeignKey(Tema,
|
tema = models.ForeignKey(Tema,
|
||||||
on_delete=models.PROTECT, # Pokud chci mazat téma, musím si Node pořešit ručně
|
on_delete=models.PROTECT, # Pokud chci mazat téma, musím si Node pořešit ručně
|
||||||
verbose_name = "téma v čísle")
|
verbose_name = "téma v čísle")
|
||||||
def __str__(self):
|
|
||||||
return 'TemaVCisleNode: tema: '+str(self.tema)
|
def aktualizuj_nazev(self):
|
||||||
|
self.nazev = "TemaVCisleNode: "+str(self.tema)
|
||||||
|
|
||||||
class KonferaNode(TreeNode):
|
class KonferaNode(TreeNode):
|
||||||
class Meta:
|
class Meta:
|
||||||
|
@ -1230,8 +1325,9 @@ class KonferaNode(TreeNode):
|
||||||
verbose_name = "konfera",
|
verbose_name = "konfera",
|
||||||
null=True,
|
null=True,
|
||||||
blank=False)
|
blank=False)
|
||||||
def __str__(self):
|
|
||||||
return 'KonferaNode: '+str(self.konfera)
|
def aktualizuj_nazev(self):
|
||||||
|
self.nazev = "KonferaNode: "+str(self.konfera)
|
||||||
|
|
||||||
class ClanekNode(TreeNode):
|
class ClanekNode(TreeNode):
|
||||||
class Meta:
|
class Meta:
|
||||||
|
@ -1243,8 +1339,9 @@ class ClanekNode(TreeNode):
|
||||||
verbose_name = "článek",
|
verbose_name = "článek",
|
||||||
null=True,
|
null=True,
|
||||||
blank=False)
|
blank=False)
|
||||||
def __str__(self):
|
|
||||||
return 'ClanekNode: '+str(self.clanek)
|
def aktualizuj_nazev(self):
|
||||||
|
self.nazev = "ClanekNode: "+str(self.clanek)
|
||||||
|
|
||||||
class UlohaZadaniNode(TreeNode):
|
class UlohaZadaniNode(TreeNode):
|
||||||
class Meta:
|
class Meta:
|
||||||
|
@ -1256,8 +1353,9 @@ class UlohaZadaniNode(TreeNode):
|
||||||
verbose_name = "úloha",
|
verbose_name = "úloha",
|
||||||
null=True,
|
null=True,
|
||||||
blank=False)
|
blank=False)
|
||||||
def __str__(self):
|
|
||||||
return 'UlohaZadaniNode: '+str(self.uloha)
|
def aktualizuj_nazev(self):
|
||||||
|
self.nazev = "UlohaZadaniNode: "+str(self.uloha)
|
||||||
|
|
||||||
class PohadkaNode(TreeNode):
|
class PohadkaNode(TreeNode):
|
||||||
class Meta:
|
class Meta:
|
||||||
|
@ -1268,8 +1366,9 @@ class PohadkaNode(TreeNode):
|
||||||
on_delete=models.PROTECT, # Pokud chci mazat pohádku, musím si Node pořešit ručně
|
on_delete=models.PROTECT, # Pokud chci mazat pohádku, musím si Node pořešit ručně
|
||||||
verbose_name = "pohádka",
|
verbose_name = "pohádka",
|
||||||
)
|
)
|
||||||
def __str__(self):
|
|
||||||
return 'PohadkaNode: '+str(self.pohadka)
|
def aktualizuj_nazev(self):
|
||||||
|
self.nazev = "PohadkaNode: "+str(self.pohadka)
|
||||||
|
|
||||||
class UlohaVzorakNode(TreeNode):
|
class UlohaVzorakNode(TreeNode):
|
||||||
class Meta:
|
class Meta:
|
||||||
|
@ -1281,8 +1380,9 @@ class UlohaVzorakNode(TreeNode):
|
||||||
verbose_name = "úloha",
|
verbose_name = "úloha",
|
||||||
null=True,
|
null=True,
|
||||||
blank=False)
|
blank=False)
|
||||||
def __str__(self):
|
|
||||||
return 'UlohaVzorakNode: '+str(self.uloha)
|
def aktualizuj_nazev(self):
|
||||||
|
self.nazev = "UlohaVzorakNode: "+str(self.uloha)
|
||||||
|
|
||||||
class TextNode(TreeNode):
|
class TextNode(TreeNode):
|
||||||
class Meta:
|
class Meta:
|
||||||
|
@ -1292,8 +1392,9 @@ class TextNode(TreeNode):
|
||||||
text = models.ForeignKey(Text,
|
text = models.ForeignKey(Text,
|
||||||
on_delete=models.PROTECT,
|
on_delete=models.PROTECT,
|
||||||
verbose_name = 'text')
|
verbose_name = 'text')
|
||||||
def __str__(self):
|
|
||||||
return 'TextNode: '+str(self.text)
|
def aktualizuj_nazev(self):
|
||||||
|
self.nazev = "TextNode: "+str(self.text)
|
||||||
|
|
||||||
## FIXME: Logiku přesunout do views.
|
## FIXME: Logiku přesunout do views.
|
||||||
#class VysledkyBase(SeminarModelBase):
|
#class VysledkyBase(SeminarModelBase):
|
||||||
|
|
File diff suppressed because it is too large
Load diff
BIN
seminar/static/seminar/lisak.pdf
Normal file
BIN
seminar/static/seminar/lisak.pdf
Normal file
Binary file not shown.
|
@ -86,7 +86,8 @@
|
||||||
% Tohle makro vysází samotnou obálku
|
% Tohle makro vysází samotnou obálku
|
||||||
\def\obalka#1#2#3#4#5#6#7{
|
\def\obalka#1#2#3#4#5#6#7{
|
||||||
% Horní a pravý okraj je zároveň okraj stránky, resetujeme odsazení
|
% Horní a pravý okraj je zároveň okraj stránky, resetujeme odsazení
|
||||||
\includegraphics[height=2.55cm]{lisak.eps}\hskip 1 em\vbox{%
|
\includegraphics[height=2.55cm]{lisak.pdf}
|
||||||
|
\vbox{%
|
||||||
\adresaMaM}
|
\adresaMaM}
|
||||||
\vskip 7.3 cm % Od oka
|
\vskip 7.3 cm % Od oka
|
||||||
\hskip\toskip%
|
\hskip\toskip%
|
||||||
|
|
|
@ -333,7 +333,7 @@ def gen_cisla(rnd, rocniky):
|
||||||
|
|
||||||
cislo = Cislo.objects.create(
|
cislo = Cislo.objects.create(
|
||||||
rocnik = rocnik,
|
rocnik = rocnik,
|
||||||
cislo = str(ci),
|
poradi = str(ci),
|
||||||
datum_vydani=vydano,
|
datum_vydani=vydano,
|
||||||
datum_deadline=deadline,
|
datum_deadline=deadline,
|
||||||
verejne_db=True
|
verejne_db=True
|
||||||
|
|
|
@ -634,9 +634,9 @@ def obalkyView(request,resitele):
|
||||||
tex = render(request,'seminar/archiv/obalky.tex', {'resitele': resitele}).content
|
tex = render(request,'seminar/archiv/obalky.tex', {'resitele': resitele}).content
|
||||||
|
|
||||||
tempdir = tempfile.mkdtemp()
|
tempdir = tempfile.mkdtemp()
|
||||||
with open(tempdir+"/obalky.tex","wb") as texfile:
|
with open(tempdir+"/obalky.tex","w") as texfile:
|
||||||
texfile.write(tex)
|
texfile.write(tex)
|
||||||
shutil.copy(os.path.join(settings.STATIC_ROOT, 'seminar/lisak.eps'),tempdir)
|
shutil.copy(os.path.join(settings.STATIC_ROOT, 'seminar/lisak.pdf'),tempdir)
|
||||||
subprocess.call(["pdflatex","obalky.tex"],cwd = tempdir)
|
subprocess.call(["pdflatex","obalky.tex"],cwd = tempdir)
|
||||||
|
|
||||||
with open(tempdir+"/obalky.pdf","rb") as pdffile:
|
with open(tempdir+"/obalky.pdf","rb") as pdffile:
|
||||||
|
|
Loading…
Reference in a new issue