Browse Source

Migr 005[12]: Nemazat uživatelům data

Fix #1142
export_seznamu_prednasek
Pavel "LEdoian" Turinsky 4 years ago
parent
commit
677d868d8a
  1. 13
      seminar/migrations/0051_resitel_to_osoba.py
  2. 5
      seminar/migrations/0052_user_to_organizator.py

13
seminar/migrations/0051_resitel_to_osoba.py

@ -28,26 +28,23 @@ def resitel_to_osoba(apps,schema_editor):
if u.first_name: if u.first_name:
if not o.jmeno: if not o.jmeno:
o.jmeno = u.first_name o.jmeno = u.first_name
u.first_name = 'Použij osobu!' u.first_name += ' (Uživatel!)'
elif o.jmeno == u.first_name: elif o.jmeno == u.first_name:
u.first_name = 'Použij osobu!' u.first_name += ' (Uživatel!)'
else: else:
raise ValueError('jmeno a first_name rozdílné: "{}" vs. "{}"'.format(o.jmeno, u.first_name)) raise ValueError('jmeno a first_name rozdílné: "{}" vs. "{}"'.format(o.jmeno, u.first_name))
if u.last_name: if u.last_name:
if not o.prijmeni: if not o.prijmeni:
o.prijmeni = u.last_name o.prijmeni = u.last_name
u.last_name = 'Použij osobu!' u.last_name += ' (Uživatel!)'
elif o.prijmeni == u.last_name: elif o.prijmeni == u.last_name:
u.last_name = 'Použij osobu!' u.last_name += ' (Uživatel!)'
else: else:
raise ValueError('prijmeni a last_name rozdílné: "{}" vs. "{}"'.format(o.prijmeni, u.last_name)) raise ValueError('prijmeni a last_name rozdílné: "{}" vs. "{}"'.format(o.prijmeni, u.last_name))
if u.email: if u.email:
if not o.email: if not o.email:
o.email = u.email o.email = u.email
u.email = 'Použij osobu!' elif o.email != u.email:
elif o.email == u.email:
u.email = 'Použij osobu!'
else:
raise ValueError('o.email a u.email rozdílné: "{}" vs. "{}"'.format(o.email, u.email)) raise ValueError('o.email a u.email rozdílné: "{}" vs. "{}"'.format(o.email, u.email))
u.save() u.save()

5
seminar/migrations/0052_user_to_organizator.py

@ -53,9 +53,8 @@ def spoj_k_organizatorum_osoby(apps, scema_editor):
osoba.jmeno = user.first_name osoba.jmeno = user.first_name
osoba.prijmeni = user.last_name osoba.prijmeni = user.last_name
osoba.email = user.email osoba.email = user.email
user.jmeno = "Použij osobu!" user.jmeno += " (Uživatel!)"
user.prijmeni = "Použij osobu!" user.prijmeni += " (Uživatel!)"
user.email = "Použij osobu!"
user.save() user.save()
except EndException: pass except EndException: pass

Loading…
Cancel
Save