Browse Source

Merge branch 'data_migrations' of gimli.ms.mff.cuni.cz:/akce/mam/git/mamweb into data_migrations

export_seznamu_prednasek
parent
commit
b0c97758a2
  1. 36
      seminar/migrations/0051_resitel_to_osoba.py

36
seminar/migrations/0051_resitel_to_osoba.py

@ -7,7 +7,7 @@ from django.db import migrations
def resitel_to_osoba(apps,schema_editor):
Resitel = apps.get_model('seminar','Resitel')
Osoba = apps.get_model('seminar','Osoba')
for r in Resitel.object.all():
for r in Resitel.objects.all():
o = Osoba()
o.datum_narozeni = r.datum_narozeni
o.datum_registrace = r.datum_prihlaseni
@ -26,13 +26,35 @@ def resitel_to_osoba(apps,schema_editor):
o.save()
r.osoba = o
r.save()
def osoba_to_resitel(apps, schema_editor):
Resitel = apps.get_model('seminar','Resitel')
Osoba = apps.get_model('seminar','Osoba')
for r in Resitel.objects.all():
o = r.osoba
r.datum_narozeni = o.datum_narozeni
r.datum_prihlaseni = o.datum_registrace
r.datum_souhlasu_udaje = o.datum_souhlasu_udaje
r.datum_souhlasu_zasilani = o.datum_souhlasu_zasilani
r.email = o.email
r.jmeno = o.jmeno
r.mesto = o.mesto
r.pohlavi_muz = o.pohlavi_muz
r.prijmeni = o.prijmeni
r.psc = o.psc
r.stat = o.stat
r.telefon = o.telefon
r.ulice = o.ulice
r.user = o.user
r.save()
o.delete()
class Migration(migrations.Migration):
dependencies = [
('seminar', '0050_auto_20190510_2228'),
]
dependencies = [
('seminar', '0050_auto_20190510_2228'),
]
operations = [
]
operations = [
migrations.RunPython(resitel_to_osoba, osoba_to_resitel),
]

Loading…
Cancel
Save