Merge remote-tracking branch 'refs/remotes/Gimli/data_migrations' into data_migrations
This commit is contained in:
commit
523a3ef9fb
3 changed files with 14 additions and 33 deletions
|
@ -142,28 +142,6 @@ class PrihlaskaForm(forms.Form):
|
|||
elif data.get('skola_adresa')=='':
|
||||
self.add_error('skola_adresa',forms.ValidationError('Je nutné vyplnit adresu školy'))
|
||||
|
||||
# Editační formulář bez řešitele.
|
||||
class ProfileEditFormPoMaturite(forms.Form):
|
||||
username = forms.CharField(label='Přihlašovací jméno',
|
||||
max_length=256,
|
||||
required=True)
|
||||
|
||||
jmeno = forms.CharField(label='Jméno', max_length=256, required=True)
|
||||
prijmeni = forms.CharField(label='Příjmení', max_length=256, required=True)
|
||||
pohlavi_muz = forms.ChoiceField(label='Pohlaví',
|
||||
choices = ((True,'muž'),(False,'žena')), required=True)
|
||||
email = forms.EmailField(label='E-mail',max_length=256, required=True)
|
||||
telefon = forms.CharField(widget=TelInput(),label='Telefon',max_length=256, required=False)
|
||||
datum_narozeni = forms.DateField(widget=DateInput(),label='Datum narození', required=False)
|
||||
ulice = forms.CharField(label='Ulice', max_length=256, required=False)
|
||||
mesto = forms.CharField(label='Město', max_length=256, required=False)
|
||||
psc = forms.CharField(label='PSČ', max_length=32, required=False)
|
||||
stat = forms.ChoiceField(label='Stát',
|
||||
choices = (('CZ', 'Česká Republika'),
|
||||
('SK', 'Slovenská Republika'),
|
||||
('other', 'Jiné')),
|
||||
required=False)
|
||||
stat_text = forms.CharField(label='Stát', max_length=256, required=False)
|
||||
|
||||
class ProfileEditForm(forms.Form):
|
||||
username = forms.CharField(label='Přihlašovací jméno',
|
||||
|
@ -203,7 +181,7 @@ class ProfileEditForm(forms.Form):
|
|||
|
||||
rok_maturity = forms.IntegerField(
|
||||
label='Rok maturity',
|
||||
min_value=date.today().year,
|
||||
min_value=date.today().year,
|
||||
max_value=date.today().year+8,
|
||||
required=True)
|
||||
zasilat = forms.ChoiceField(label='Kam zasílat čísla a řešení',choices = Resitel.ZASILAT_CHOICES, required=True)
|
||||
|
@ -255,6 +233,11 @@ class ProfileEditForm(forms.Form):
|
|||
# elif data.get('skola_adresa')=='':
|
||||
# self.add_error('skola_adresa',forms.ValidationError('Je nutné vyplnit adresu školy'))
|
||||
|
||||
class PoMaturiteProfileEditForm(ProfileEditForm):
|
||||
rok_maturity = forms.IntegerField(
|
||||
label='Rok maturity',
|
||||
required=True)
|
||||
|
||||
class VlozReseniForm(forms.Form):
|
||||
#FIXME jen podproblémy daného problému
|
||||
problem = forms.ModelChoiceField(label='Problém',queryset=m.Problem.objects.all())
|
||||
|
|
|
@ -61,7 +61,6 @@
|
|||
{% include "seminar/profil/prihlaska_field.html" with field=form.stat_text id="id_li_stat_text"%}
|
||||
</table>
|
||||
|
||||
{% if not po_maturite %} {# Vysloužilým účastníkům skrýt editaci školy apod. #}
|
||||
<hr>
|
||||
|
||||
<h4>
|
||||
|
@ -96,7 +95,6 @@
|
|||
</table>
|
||||
|
||||
<hr>
|
||||
{% endif %}
|
||||
|
||||
<input type="submit" value="Změnit">
|
||||
</form>
|
||||
|
|
|
@ -26,7 +26,7 @@ import seminar.models as m
|
|||
from seminar.models import Problem, Cislo, Reseni, Nastaveni, Rocnik, Soustredeni, Organizator, Resitel, Novinky, Soustredeni_Ucastnici, Pohadka, Tema, Clanek, Osoba, Skola # Tohle je stare a chceme se toho zbavit. Pouzivejte s.ToCoChci
|
||||
#from .models import VysledkyZaCislo, VysledkyKCisluZaRocnik, VysledkyKCisluOdjakziva
|
||||
from seminar import utils, treelib
|
||||
from seminar.forms import PrihlaskaForm, LoginForm, ProfileEditForm, ProfileEditFormPoMaturite
|
||||
from seminar.forms import PrihlaskaForm, LoginForm, ProfileEditForm, PoMaturiteProfileEditForm
|
||||
import seminar.forms as f
|
||||
import seminar.templatetags.treenodes as tnltt
|
||||
import seminar.views.views_rest as vr
|
||||
|
@ -1095,21 +1095,21 @@ def resitelEditView(request):
|
|||
user_edit = osoba_edit.user
|
||||
## Vytvoření slovníku, kterým předvyplním formulář
|
||||
prefill_1=model_to_dict(user_edit)
|
||||
if resitel_edit and resitel_edit.rok_maturity >= date.today().year:
|
||||
if resitel_edit:
|
||||
prefill_2=model_to_dict(resitel_edit)
|
||||
prefill_1.update(prefill_2)
|
||||
prefill_3=model_to_dict(osoba_edit)
|
||||
prefill_1.update(prefill_3)
|
||||
if 'datum_narozeni' in prefill_1:
|
||||
prefill_1['datum_narozeni'] = str(prefill_1['datum_narozeni'])
|
||||
if resitel_edit and resitel_edit.rok_maturity < date.today().year:
|
||||
form = ProfileEditFormPoMaturite(initial=prefill_1)
|
||||
if 'rok_maturity' not in prefill_1 or prefill_1['rok_maturity'] < date.today().year:
|
||||
form = PoMaturiteProfileEditForm(initial=prefill_1)
|
||||
else:
|
||||
form = ProfileEditForm(initial=prefill_1)
|
||||
## Změna údajů a jejich uložení
|
||||
if request.method == 'POST':
|
||||
if resitel_edit and resitel_edit.rok_maturity < date.today().year:
|
||||
form = ProfileEditFormPoMaturite(request.POST)
|
||||
if 'rok_maturity' not in prefill_1 or prefill_1['rok_maturity'] < date.today().year:
|
||||
form = PoMaturiteProfileEditForm(request.POST)
|
||||
else:
|
||||
form = ProfileEditForm(request.POST)
|
||||
if form.is_valid():
|
||||
|
@ -1133,7 +1133,7 @@ def resitelEditView(request):
|
|||
## Neznámá země
|
||||
msg = "Unknown country {}".format(fcd['stat_text'])
|
||||
|
||||
if resitel_edit and resitel_edit.rok_maturity >= date.today().year:
|
||||
if resitel_edit:
|
||||
## Změny v řešiteli
|
||||
resitel_edit.skola = fcd['skola']
|
||||
resitel_edit.rok_maturity = fcd['rok_maturity']
|
||||
|
@ -1149,7 +1149,7 @@ def resitelEditView(request):
|
|||
return formularOKView(request)
|
||||
else:
|
||||
## Stránka před odeslaním formuláře = předvyplněný formulář
|
||||
return render(request, 'seminar/profil/edit.html', {'form': form, 'po_maturite': resitel_edit and resitel_edit.rok_maturity < date.today().year})
|
||||
return render(request, 'seminar/profil/edit.html', {'form': form})
|
||||
|
||||
def prihlaskaView(request):
|
||||
generic_logger = logging.getLogger('seminar.prihlaska')
|
||||
|
|
Loading…
Reference in a new issue