Browse Source

Úpravy okolí, aby reflektovaly změny modelu

middleware_test
Pavel 'LEdoian' Turinsky 5 years ago
parent
commit
f01aed8af2
  1. 19
      seminar/admin.py
  2. 103
      seminar/migrations/0080_zruseni_claneknode_a_konferanode.py
  3. 10
      seminar/models.py
  4. 7
      seminar/testutils.py

19
seminar/admin.py

@ -35,6 +35,7 @@ class ProblemAdmin(PolymorphicParentModelAdmin):
m.Tema,
m.Clanek,
m.Uloha,
m.Konfera,
]
@admin.register(m.Tema)
@ -52,6 +53,11 @@ class UlohaAdmin(PolymorphicChildModelAdmin):
base_model = m.Uloha
show_in_index = True
@admin.register(m.Konfera)
class KonferaAdmin(PolymorphicChildModelAdmin):
base_model = m.Konfera
show_in_index = True
class TextAdminInline(admin.TabularInline):
model = m.Text
exclude = ['text_zkraceny_set','text_zkraceny']
@ -82,7 +88,6 @@ class ReseniAdmin(ReverseModelAdmin):
admin.site.register(m.Hodnoceni)
admin.site.register(m.Pohadka)
admin.site.register(m.Konfera)
admin.site.register(m.Obrazek)
@ -97,8 +102,6 @@ class TreeNodeAdmin(PolymorphicParentModelAdmin):
m.CisloNode,
m.MezicisloNode,
m.TemaVCisleNode,
m.KonferaNode,
m.ClanekNode,
m.UlohaZadaniNode,
m.PohadkaNode,
m.UlohaVzorakNode,
@ -136,16 +139,6 @@ class TemaVCisleNodeAdmin(PolymorphicChildModelAdmin):
base_model = m.TemaVCisleNode
show_in_index = True
@admin.register(m.KonferaNode)
class KonferaNodeAdmin(PolymorphicChildModelAdmin):
base_model = m.KonferaNode
show_in_index = True
@admin.register(m.ClanekNode)
class ClanekNodeAdmin(PolymorphicChildModelAdmin):
base_model = m.ClanekNode
show_in_index = True
@admin.register(m.UlohaZadaniNode)
class UlohaZadaniNodeAdmin(PolymorphicChildModelAdmin):
base_model = m.UlohaZadaniNode

103
seminar/migrations/0080_zruseni_claneknode_a_konferanode.py

@ -0,0 +1,103 @@
# Generated by Django 2.2.12 on 2020-04-01 20:54
# Fixed by Pavel, 2020-01-04 20:56 UTC
# This is quite possibly a bug in Django.
from django.db import migrations, models
import django.db.models.deletion
def vyrob_dummy_problemy(apps, schema_editor):
Problem = apps.get_model('seminar', 'Problem')
Konfera = apps.get_model('seminar', 'Konfera')
for k in Konfera.objects.all():
pr = Problem.objects.create(nazev=k.nazev,
garant=k.organizator)
pr.save()
k.problem_ptr = pr
k.save()
class Migration(migrations.Migration):
dependencies = [
('contenttypes', '0002_remove_content_type_name'),
('seminar', '0079_clanek_resitelsky'),
]
operations = [
migrations.CreateModel(
name='OrgTextNode',
fields=[
('treenode_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='seminar.TreeNode')),
('org_verejny', models.BooleanField(default=True, help_text='Pokud ano, bude org pod článkem podepsaný', verbose_name='Org je veřejný?')),
('organizator', models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, to='seminar.Organizator', verbose_name='Organizátor')),
],
options={
'verbose_name': 'Organizátorský článek (Node)',
'verbose_name_plural': 'Organizátorské články (Node)',
'db_table': 'seminar_nodes_orgtextnode',
},
bases=('seminar.treenode',),
),
migrations.RenameModel(
old_name='OtisteneReseniNode',
new_name='ReseniNode',
),
migrations.RemoveField(
model_name='konferanode',
name='konfera',
),
migrations.RemoveField(
model_name='konferanode',
name='treenode_ptr',
),
migrations.RemoveField(
model_name='clanek',
name='cislo',
),
migrations.RemoveField(
model_name='clanek',
name='resitelsky',
),
migrations.RemoveField(
model_name='reseni',
name='text_zkraceny',
),
migrations.AddField(
model_name='konfera',
name='problem_ptr',
field=models.OneToOneField(auto_created=True, null=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='seminar.Problem'),
preserve_default=False,
),
migrations.RunPython(vyrob_dummy_problemy),
migrations.RemoveField(
model_name='konfera',
name='id',
),
migrations.RemoveField(
model_name='konfera',
name='nazev',
),
migrations.RemoveField(
model_name='konfera',
name='organizator',
),
migrations.RemoveField(
model_name='konfera',
name='poznamka',
),
migrations.RemoveField(
model_name='konfera',
name='reseni',
),
migrations.AlterField(
model_name='reseni',
name='text_cely',
field=models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='reseni_cely_set', to='seminar.ReseniNode', verbose_name='Plná verze textu řešení'),
),
migrations.DeleteModel(
name='ClanekNode',
),
migrations.DeleteModel(
name='KonferaNode',
),
]

10
seminar/models.py

@ -868,7 +868,7 @@ class Reseni(SeminarModelBase):
forma = models.CharField('forma řešení', max_length=16, choices=FORMA_CHOICES, blank=False,
default=FORMA_EMAIL)
text_cely = models.OneToOneField(ReseniNode, verbose_name='Plná verze textu řešení',
text_cely = models.OneToOneField('ReseniNode', verbose_name='Plná verze textu řešení',
blank=True, null=True, related_name="reseni_cely_set",
on_delete=models.PROTECT)
@ -1085,8 +1085,6 @@ class Konfera(Problem):
db_table = 'seminar_konfera'
verbose_name = 'Konfera'
verbose_name_plural = 'Konfery'
# Interní ID
id = models.AutoField(primary_key = True)
anotace = models.TextField('anotace', blank=True,
help_text='Popis, o čem bude konfera.')
@ -1334,9 +1332,9 @@ class TemaVCisleNode(TreeNode):
class OrgTextNode(TreeNode):
class Meta:
db_table = 'seminar_nodes_clanek'
verbose_name = 'Článek (Node)'
verbose_name_plural = 'Články (Node)'
db_table = 'seminar_nodes_orgtextnode'
verbose_name = 'Organizátorský článek (Node)'
verbose_name_plural = 'Organizátorské články (Node)'
organizator = models.ForeignKey(Organizator,
null=False,

7
seminar/testutils.py

@ -9,7 +9,7 @@ from django.db import transaction
import unidecode
import logging
from seminar.models import Skola, Resitel, Rocnik, Cislo, Problem, Reseni, PrilohaReseni, Nastaveni, Soustredeni, Soustredeni_Ucastnici, Soustredeni_Organizatori, Osoba, Organizator, Prijemce, Tema, Uloha, Konfera, KonferaNode, TextNode, UlohaVzorakNode, RocnikNode, CisloNode, TemaVCisleNode, Text, Hodnoceni, UlohaZadaniNode, Novinky, TreeNode
from seminar.models import Skola, Resitel, Rocnik, Cislo, Problem, Reseni, PrilohaReseni, Nastaveni, Soustredeni, Soustredeni_Ucastnici, Soustredeni_Organizatori, Osoba, Organizator, Prijemce, Tema, Uloha, Konfera, TextNode, UlohaVzorakNode, RocnikNode, CisloNode, TemaVCisleNode, Text, Hodnoceni, UlohaZadaniNode, Novinky, TreeNode
from django.contrib.flatpages.models import FlatPage
from django.contrib.sites.models import Site
@ -336,7 +336,7 @@ def gen_konfery(size, rnd, organizatori, resitele, soustredeni):
nazev=rnd.choice(['Pozorování', 'Zkoumání', 'Modelování', 'Počítání', 'Zkoušení']) + rnd.choice([' vlastností', ' jevů', ' charakteristik']) + rnd.choice([' vektorových prostorů', ' kinetické terorie látek', ' molekulární biologie', ' syntentických stromů']),
anotace=lorem.paragraph(),
abstrakt=lorem.paragraph(),
organizator=rnd.choice(organizatori),
garant=rnd.choice(organizatori),
soustredeni=rnd.choice(soustredeni),
typ_prezentace=rnd.choice(['veletrh', 'prezentace']))
ucastnici_sous = list(konfera.soustredeni.ucastnici.all())
@ -346,9 +346,6 @@ def gen_konfery(size, rnd, organizatori, resitele, soustredeni):
# Konfery_Ucastnici.objects.create(resitel=res, konfera=konfera)
konfera.save()
konfery.append(konfera)
konferanode = KonferaNode.objects.create(konfera=konfera)
konferanode.save()
return konfery
def gen_cisla(rnd, rocniky):

Loading…
Cancel
Save