|
|
@ -1027,15 +1027,16 @@ def prihlaska_log_gdpr_safe(logger, gdpr_logger, msg, form_data): |
|
|
|
|
|
|
|
from django.forms.models import model_to_dict |
|
|
|
def resitelEditView(request): |
|
|
|
err_logger = logging.getLogger('seminar.prihlaska.problem') |
|
|
|
## Načtení objektu Osoba a Resitel, patrici k aktuálně přihlášenému uživately |
|
|
|
u = request.user |
|
|
|
osoba_edit = Osoba.objects.get(user=u) |
|
|
|
resitel_edit = osoba_edit.resitel |
|
|
|
user_edit = osoba_edit.user |
|
|
|
## Vytvoření slovníku, kterým předvyplním formulář |
|
|
|
prefill_1=model_to_dict(osoba_edit) |
|
|
|
prefill_1=model_to_dict(user_edit) |
|
|
|
prefill_2=model_to_dict(resitel_edit) |
|
|
|
prefill_3=model_to_dict(user_edit) |
|
|
|
prefill_3=model_to_dict(osoba_edit) |
|
|
|
prefill_1.update(prefill_2) |
|
|
|
prefill_1.update(prefill_3) |
|
|
|
form = EditForm(initial=prefill_1) |
|
|
@ -1043,7 +1044,35 @@ def resitelEditView(request): |
|
|
|
if request.method == 'POST': |
|
|
|
form = EditForm(request.POST) |
|
|
|
if form.is_valid(): |
|
|
|
osoba_edit.prijmeni = 'NOVOTA' |
|
|
|
## Změny v osobě |
|
|
|
fcd = form.cleaned_data |
|
|
|
osoba_edit.jmeno = fcd['jmeno'] |
|
|
|
osoba_edit.prijmeni = fcd['prijmeni'] |
|
|
|
osoba_edit.pohlavi_muz = fcd['pohlavi_muz'] |
|
|
|
osoba_edit.email = fcd['email'] |
|
|
|
osoba_edit.telefon = fcd['telefon'] |
|
|
|
osoba_edit.ulice = fcd['ulice'] |
|
|
|
osoba_edit.mesto = fcd['mesto'] |
|
|
|
osoba_edit.psc = fcd['psc'] |
|
|
|
## Změny v osobě s podmínkami |
|
|
|
if fcd.get('spam',False): |
|
|
|
osoba_edit.datum_souhlasu_zasilani = date.today() |
|
|
|
if fcd.get('stat','') in ('CZ','SK'): |
|
|
|
osoba_edit.stat = fcd['stat'] |
|
|
|
else: |
|
|
|
## Neznámá země |
|
|
|
msg = "Unknown country {}".format(fcd['stat_text']) |
|
|
|
|
|
|
|
## Změny v řešiteli |
|
|
|
resitel_edit.skola = fcd['skola'] |
|
|
|
resitel_edit.rok_maturity = fcd['rok_maturity'] |
|
|
|
resitel_edit.zasilat = fcd['zasilat'] |
|
|
|
if fcd.get('skola'): |
|
|
|
resitel_edit.skola = fcd['skola'] |
|
|
|
else: |
|
|
|
# Unknown school - log it |
|
|
|
msg = "Unknown school {}, {}".format(fcd['skola_nazev'],fcd['skola_adresa']) |
|
|
|
resitel_edit.save() |
|
|
|
osoba_edit.save() |
|
|
|
return HttpResponseRedirect('/thanks/') |
|
|
|
else: |
|
|
|