|
|
|
# Generated by Django 1.11.20 on 2019-05-10 20:44
|
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
|
|
|
from django.db import migrations
|
|
|
|
|
|
|
|
from datetime import date
|
|
|
|
|
|
|
|
def resitel_to_osoba(apps,schema_editor):
|
|
|
|
Resitel = apps.get_model('seminar','Resitel')
|
|
|
|
Osoba = apps.get_model('seminar','Osoba')
|
|
|
|
for r in Resitel.objects.all():
|
|
|
|
o = Osoba()
|
|
|
|
o.datum_narozeni = r.datum_narozeni
|
|
|
|
o.datum_registrace = r.datum_prihlaseni if r.datum_prihlaseni else date.max # Myslím si, že None by způsobilo použití defaultu
|
|
|
|
o.datum_souhlasu_udaje = r.datum_souhlasu_udaje
|
|
|
|
o.datum_souhlasu_zasilani = r.datum_souhlasu_zasilani
|
|
|
|
o.email = r.email
|
|
|
|
o.jmeno = r.jmeno
|
|
|
|
o.mesto = r.mesto
|
|
|
|
o.pohlavi_muz = r.pohlavi_muz
|
|
|
|
o.prijmeni = r.prijmeni
|
|
|
|
o.psc = r.psc
|
|
|
|
o.stat = r.stat
|
|
|
|
o.telefon = r.telefon
|
|
|
|
o.ulice = r.ulice
|
|
|
|
o.user = r.user
|
|
|
|
o.poznamka += f'\nWEB DEBUG: Osoba pro řešitele {r.id}'
|
|
|
|
if o.user:
|
|
|
|
u = o.user
|
|
|
|
if u.first_name:
|
|
|
|
if not o.jmeno:
|
|
|
|
o.jmeno = u.first_name
|
|
|
|
u.first_name += ' (Uživatel!)'
|
|
|
|
elif o.jmeno == u.first_name:
|
|
|
|
u.first_name += ' (Uživatel!)'
|
|
|
|
else:
|
|
|
|
raise ValueError('jmeno a first_name rozdílné: "{}" vs. "{}"'.format(o.jmeno, u.first_name))
|
|
|
|
if u.last_name:
|
|
|
|
if not o.prijmeni:
|
|
|
|
o.prijmeni = u.last_name
|
|
|
|
u.last_name += ' (Uživatel!)'
|
|
|
|
elif o.prijmeni == u.last_name:
|
|
|
|
u.last_name += ' (Uživatel!)'
|
|
|
|
else:
|
|
|
|
raise ValueError('prijmeni a last_name rozdílné: "{}" vs. "{}"'.format(o.prijmeni, u.last_name))
|
|
|
|
if u.email:
|
|
|
|
if not o.email:
|
|
|
|
o.email = u.email
|
|
|
|
elif o.email != u.email:
|
|
|
|
raise ValueError('o.email a u.email rozdílné: "{}" vs. "{}"'.format(o.email, u.email))
|
|
|
|
u.save()
|
|
|
|
|
|
|
|
|
|
|
|
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', '0066c_reseninode'),
|
|
|
|
]
|
|
|
|
|
|
|
|
operations = [
|
|
|
|
migrations.RunPython(resitel_to_osoba, osoba_to_resitel),
|
|
|
|
]
|