|
@ -1241,6 +1241,7 @@ def prihlaskaView(request): |
|
|
psc = fcd.get('psc',''), |
|
|
psc = fcd.get('psc',''), |
|
|
poznamka = str(fcd) |
|
|
poznamka = str(fcd) |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
if fcd.get('spam',False): |
|
|
if fcd.get('spam',False): |
|
|
o.datum_souhlasu_zasilani = date.today() |
|
|
o.datum_souhlasu_zasilani = date.today() |
|
|
if fcd.get('stat','') in ('CZ','SK'): |
|
|
if fcd.get('stat','') in ('CZ','SK'): |
|
@ -1250,6 +1251,32 @@ def prihlaskaView(request): |
|
|
msg = "Unknown country {}".format(fcd['stat_text']) |
|
|
msg = "Unknown country {}".format(fcd['stat_text']) |
|
|
err_logger.warn(msg + str(form_hash)) |
|
|
err_logger.warn(msg + str(form_hash)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Dovolujeme doregistraci uživatele pro existující mail, takže naopak chceme doplnit/aktualizovat údaje do stávajícího objektu |
|
|
|
|
|
try: |
|
|
|
|
|
orig_osoba = m.Osoba.objects.get(email=fcd['email']) |
|
|
|
|
|
orig_osoba.poznamka += f'\nDOREGISTRACE K EXISTUJÍCÍMU E-MAILU, diff níže.' |
|
|
|
|
|
except m.Osoba.DoesNotExist: |
|
|
|
|
|
# Trik: Budeme aktualizovat údaje nové osoby, takže se asi nic nezmění, ale fungovat to bude. |
|
|
|
|
|
orig_osoba = o |
|
|
|
|
|
|
|
|
|
|
|
# Porovnání údajů |
|
|
|
|
|
assert orig_osoba.user is None, "Právě-registrující-se osoba už má Uživatele!" |
|
|
|
|
|
osoba_attrs = ['jmeno', 'prijmeni', 'pohlavi_muz', 'email', 'telefon', 'datum_narozeni', 'ulice', 'mesto', 'psc', 'stat', 'datum_souhlasu_udaje', 'datum_souhlasu_zasilani', 'datum_registrace'] |
|
|
|
|
|
diffattrs = [] |
|
|
|
|
|
for attr in osoba_attrs: |
|
|
|
|
|
new = getattr(o, attr) |
|
|
|
|
|
old = getattr(orig_osoba, attr) |
|
|
|
|
|
if new != old: |
|
|
|
|
|
orig_osoba.poznamka += f'\nRozdíl v {attr}: Původní {old}, nový {new}' |
|
|
|
|
|
diffattrs.append(f'Osoba.{attr}') |
|
|
|
|
|
setattr(orig_osoba, attr, new) |
|
|
|
|
|
# Datum registrace chceme původní / nižší: |
|
|
|
|
|
orig_osoba.datum_registrace = min(orig_osoba.datum_registrace, o.datum_registrace) |
|
|
|
|
|
|
|
|
|
|
|
# Od této chvíle dál je správná osoba ta "původní", novou podle formuláře si ale zachováme |
|
|
|
|
|
o, o_form = orig_osoba, o |
|
|
|
|
|
|
|
|
o.save() |
|
|
o.save() |
|
|
o.user = u |
|
|
o.user = u |
|
|
o.save() |
|
|
o.save() |
|
@ -1260,15 +1287,35 @@ def prihlaskaView(request): |
|
|
zasilat_cislo_emailem = fcd['zasilat_cislo_emailem'] |
|
|
zasilat_cislo_emailem = fcd['zasilat_cislo_emailem'] |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
r.save() |
|
|
|
|
|
r.osoba = o |
|
|
|
|
|
if fcd.get('skola'): |
|
|
if fcd.get('skola'): |
|
|
r.skola = fcd['skola'] |
|
|
r.skola = fcd['skola'] |
|
|
else: |
|
|
else: |
|
|
# Unknown school - log it |
|
|
# Unknown school - log it |
|
|
msg = "Unknown school {}, {}".format(fcd['skola_nazev'],fcd['skola_adresa']) |
|
|
msg = "Unknown school {}, {}".format(fcd['skola_nazev'],fcd['skola_adresa']) |
|
|
err_logger.warn(msg + str(form_hash)) |
|
|
err_logger.warn(msg + str(form_hash)) |
|
|
|
|
|
|
|
|
|
|
|
# Porovnání údajů u řešitele |
|
|
|
|
|
try: |
|
|
|
|
|
orig_resitel = o.resitel |
|
|
|
|
|
orig_resitel.poznamka += f'\nDOREGISTRACE ŘEŠITELE, diff:' |
|
|
|
|
|
except m.Resitel.DoesNotExist: |
|
|
|
|
|
# Stejný trik: |
|
|
|
|
|
orig_resitel = r |
|
|
|
|
|
resitel_attrs = ['skola', 'poznamka', 'rok_maturity', 'zasilat', 'zasilat_cislo_emailem'] |
|
|
|
|
|
for attr in resitel_attrs: |
|
|
|
|
|
new = getattr(r, attr) |
|
|
|
|
|
old = getattr(orig_resitel, attr) |
|
|
|
|
|
if new != old: |
|
|
|
|
|
orig_resitel.poznamka += f'\nRozdíl v {attr}: Původní {old}, nový {new}' |
|
|
|
|
|
diffattrs.append(f'Resitel.{attr}') |
|
|
|
|
|
setattr(orig_resitel, attr, new) |
|
|
|
|
|
r, r_form = orig_resitel, r |
|
|
|
|
|
|
|
|
r.save() |
|
|
r.save() |
|
|
|
|
|
r.osoba = o # Tohle by mělo být bezpečné… |
|
|
|
|
|
r.save() |
|
|
|
|
|
|
|
|
|
|
|
if diffattrs: err_logger.warning(f'Different fields when matching Řešitel id {r.id} or Osoba id {o.id}: {diffattrs}') |
|
|
|
|
|
|
|
|
uid = urlsafe_base64_encode(force_bytes(u.pk)) |
|
|
uid = urlsafe_base64_encode(force_bytes(u.pk)) |
|
|
token = PasswordResetTokenGenerator().make_token(u) |
|
|
token = PasswordResetTokenGenerator().make_token(u) |
|
|