Moved most form field initial values from forms to settings.
This commit is contained in:
@@ -83,17 +83,17 @@ class EventCreateForm(ChainedForm):
|
||||
ski_lift = session_data.get('ski_lift', False)
|
||||
terrain = session_data.get('terrain', None)
|
||||
country = session_data.get('country', None)
|
||||
last_day = session_data.get('last_day', None)
|
||||
overnight = bool(session_data.get('last_day', None))
|
||||
|
||||
if sport == 'S' and ski_lift:
|
||||
matrix_key = 'K'
|
||||
elif sport == 'W' and not last_day:
|
||||
elif sport == 'W' and not overnight:
|
||||
matrix_key = '0'
|
||||
elif sport == 'W' and terrain != 'alpine':
|
||||
matrix_key = 'A'
|
||||
elif sport == 'W':
|
||||
matrix_key = 'B'
|
||||
elif terrain != 'alpine' and not last_day:
|
||||
elif terrain != 'alpine' and not overnight:
|
||||
matrix_key = 'C'
|
||||
elif terrain != 'alpine':
|
||||
matrix_key = 'D'
|
||||
@@ -118,12 +118,10 @@ class ModeForm(EventCreateForm):
|
||||
_next_form_name = 'LocationForm'
|
||||
|
||||
mode = forms.ChoiceField(choices=choices.MODE_CHOICES,
|
||||
initial='joint',
|
||||
label=_(u'Veranstaltungsart'),
|
||||
widget=forms.RadioSelect())
|
||||
|
||||
sport = forms.ChoiceField(choices=choices.SPORT_CHOICES,
|
||||
initial='W',
|
||||
label=_(u'Spielart'),
|
||||
widget=forms.RadioSelect())
|
||||
|
||||
@@ -133,7 +131,6 @@ class ModeForm(EventCreateForm):
|
||||
)
|
||||
|
||||
level = forms.ChoiceField(choices=choices.LEVEL_CHOICES,
|
||||
initial='beginner',
|
||||
label=_(u'Schwierigkeitsnivau'),
|
||||
widget=forms.RadioSelect())
|
||||
|
||||
@@ -258,11 +255,9 @@ class LocationForm(EventCreateForm):
|
||||
_next_form_name = 'ApproachForm'
|
||||
|
||||
country = LazyTypedChoiceField(choices=choices.COUNTRY_CHOICES,
|
||||
initial='DE',
|
||||
label=_(u'Land'))
|
||||
|
||||
terrain = forms.ChoiceField(choices=choices.TERRAIN_CHOICES,
|
||||
initial='submountains',
|
||||
label=_(u'Gelände'),
|
||||
help_text=_(u'Relevant für die Vorauswahl weiterer Felder.'),
|
||||
)
|
||||
@@ -286,28 +281,18 @@ class LocationForm(EventCreateForm):
|
||||
sport = session_data.get('sport', None)
|
||||
last_day = session_data.get('last_day', None)
|
||||
if sport == 'B':
|
||||
self.fields['terrain'].initial = 'alpine'
|
||||
self.fields['country'].initial = 'FR'
|
||||
self.fields['location'].widget.attrs['placeholder'] = u'z.B. Chamonix, Mont-Blanc-Gruppe'
|
||||
elif sport == 'K':
|
||||
self.fields['terrain'].initial = 'crag'
|
||||
self.fields['location'].widget.attrs['placeholder'] = u'z.B. Battert, Baden-Baden'
|
||||
elif sport == 'M':
|
||||
self.fields['terrain'].initial = 'submountains'
|
||||
self.fields['location'].widget.attrs['placeholder'] = u'z.B. Pfälzerwald'
|
||||
elif sport == 'S' and last_day:
|
||||
self.fields['terrain'].initial = 'alpine'
|
||||
self.fields['country'].initial = 'AT'
|
||||
self.fields['location'].widget.attrs['placeholder'] = u'z.B. Obergurgl, Ötztaler Alpen'
|
||||
elif sport == 'S':
|
||||
self.fields['terrain'].initial = 'submountains'
|
||||
self.fields['location'].widget.attrs['placeholder'] = u'z.B. Todtnau, Schwarzwald'
|
||||
elif sport == 'W' and last_day:
|
||||
self.fields['terrain'].initial = 'alpine'
|
||||
self.fields['country'].initial = 'AT'
|
||||
self.fields['location'].widget.attrs['placeholder'] = u'z.B. Ötztaler Alpen'
|
||||
elif sport == 'W':
|
||||
self.fields['terrain'].initial = 'submountains'
|
||||
self.fields['location'].widget.attrs['placeholder'] = u'z.B. Maikammer, Pfalz'
|
||||
|
||||
|
||||
@@ -382,7 +367,6 @@ class ApproachForm(EventCreateForm):
|
||||
)
|
||||
|
||||
meals = forms.ChoiceField(choices=choices.MEALS_CHOICES,
|
||||
initial='NONE',
|
||||
label=_(u'Verpflegung'),
|
||||
)
|
||||
meals_other = forms.CharField(required=False,
|
||||
@@ -394,9 +378,6 @@ class ApproachForm(EventCreateForm):
|
||||
super(ApproachForm, self)._proceed_session_data(session_data)
|
||||
|
||||
last_day = session_data.get('last_day', None)
|
||||
sport = session_data.get('sport', None)
|
||||
country = session_data.get('country', None)
|
||||
terrain = session_data.get('terrain', None)
|
||||
|
||||
self.fields['transport_other'].widget.attrs['placeholder'] = _(u'Nebenstehendes Feld beachten')
|
||||
self.fields['meeting_point_other'].widget.attrs['placeholder'] = _(u'Nebenstehendes Feld beachten')
|
||||
@@ -404,14 +385,6 @@ class ApproachForm(EventCreateForm):
|
||||
self.fields['accommodation_other'].widget.attrs['placeholder'] = _(u'Nebenstehendes Feld beachten')
|
||||
self.fields['meals_other'].widget.attrs['placeholder'] = _(u'Nebenstehendes Feld beachten')
|
||||
|
||||
if terrain == 'alpine':
|
||||
self.fields['accommodation'].initial = 'hut'
|
||||
|
||||
if sport in ('M', 'W'):
|
||||
if country == 'DE' and terrain == 'submountains':
|
||||
self.fields['transport'].initial = 'public'
|
||||
self.fields['meeting_point'].initial = 'hbf'
|
||||
|
||||
if not last_day:
|
||||
self.fields['basecamp'].widget = forms.HiddenInput()
|
||||
self.fields['accommodation'].widget = forms.HiddenInput()
|
||||
@@ -476,70 +449,6 @@ class RequirementsForm(EventCreateForm):
|
||||
},
|
||||
bootstrap_version=3))
|
||||
|
||||
def _proceed_session_data(self, session_data):
|
||||
super(RequirementsForm, self)._proceed_session_data(session_data)
|
||||
|
||||
sport = session_data.get('sport', None)
|
||||
level = session_data.get('level', None)
|
||||
terrain = session_data.get('terrain', None)
|
||||
|
||||
if sport == 'B':
|
||||
self.fields['equipment'].initial = u'%s (%s)' % (
|
||||
_(u'Steigeisen*, Pickel*, Klettergurt*, Steinschlaghelm*,'
|
||||
u' Gletscherbrille, wasserfeste Kleidung, Gamaschen'),
|
||||
_(u'* Ausrüstung kann ggf. von der Sektion geliehen werden')
|
||||
)
|
||||
|
||||
if level == 'beginner':
|
||||
self.fields['requirements'].initial = _(u'Kondition für ganztätige Aktivität im Freien'
|
||||
u' mit Auf- und Abstiegen bis zu 1000 Hm.')
|
||||
else:
|
||||
self.fields['requirements'].initial = _(u'Sicheres Vorsteigen am Fels im 4. Grad UIAA.'
|
||||
u' Grundkentnisse Hochtouren, Spaltenbergung.'
|
||||
u' Kondition für Auf- und Abstiege bis zu 1300 Hm.')
|
||||
elif sport == 'K':
|
||||
self.fields['equipment'].initial = u'%s (%s)' % (
|
||||
_(u'Kletterschuhe, Hüftgurt*, Steinschlaghelm*'),
|
||||
_(u'* Ausrüstung kann ggf. von der Sektion geliehen werden')
|
||||
)
|
||||
if level == 'beginner':
|
||||
self.fields['requirements'].initial = _(u'Sicheres Klettern im 4. Grad UIAA.'
|
||||
u' Beherrschen der Sicherungstechnik.')
|
||||
else:
|
||||
self.fields['requirements'].initial = _(u'Sicheres Vorsteigen am Fels im 5. Grad UIAA.'
|
||||
u' Beherrschen der Sicherungs- und Abseiltechnik.')
|
||||
elif sport == 'M':
|
||||
self.fields['equipment'].initial = _(u'Funktionstüchtiges MTB (bitte vorher überprüfen), Fahrrad-Helm'
|
||||
u' und Radhandschuhe sind zwingend erforderlich,'
|
||||
u' Brille und Protektoren empfehlenswert.'
|
||||
u' Die Sattelstütze muss sich tief versenken lassen.')
|
||||
if level == 'beginner':
|
||||
self.fields['requirements'].initial = _(u'Kondition für Radtouren bis 30 km und 500 Hm'
|
||||
u' in ca. 3 Stunden.')
|
||||
else:
|
||||
self.fields['requirements'].initial = _(u'Kondition für Radtouren bis 60 km und 1000 Hm'
|
||||
u' in ca. 5 Stunden.'
|
||||
u' Sicheres Beherrschen von Trails der Schwierigkeit S1.')
|
||||
elif sport == 'S':
|
||||
self.fields['equipment'].initial = u'%s (%s)' % (
|
||||
_(u'Komplette Skitourenausrüstung inkl. Ski, Lawinen-Pieps*, Schaufel* und Sonde*'),
|
||||
_(u'* Ausrüstung kann ggf. von der Sektion geliehen werden')
|
||||
)
|
||||
if level == 'beginner':
|
||||
self.fields['requirements'].initial = _(u'Sicheres Skifahren und erste Erfahrungen abseits'
|
||||
u' der gespurten Piste.')
|
||||
else:
|
||||
self.fields['requirements'].initial = _(u'Mittelschwere, lange Skitouren bis 1500 Hm.'
|
||||
u' Solide Aufstiegs- und Abfahrtstechnik.')
|
||||
elif sport == 'W':
|
||||
if terrain == 'alpine':
|
||||
self.fields['equipment'].initial = _(u'Feste, knöchelhohe Wanderschuhe, Regenschutz')
|
||||
self.fields['requirements'].initial = _(u'Kondition für 20km und 600 Hm in ca. 7 Stunden Gehzeit.'
|
||||
u' Trittsicherheit (mittelschwere Wege).')
|
||||
else:
|
||||
self.fields['equipment'].initial = _(u'Festes Schuhwerk, Regenschutz')
|
||||
self.fields['requirements'].initial = _(u'Gehzeit X-Y Stunden, ca. X km, ca. X Hm')
|
||||
|
||||
|
||||
class DescriptionForm(EventCreateForm):
|
||||
_form_title = _(u'Titel / Beschreibung')
|
||||
@@ -664,7 +573,6 @@ class RegistrationForm(EventCreateForm):
|
||||
label=_(u'Max. Teilnehmer'))
|
||||
|
||||
deadline = forms.ChoiceField(choices=choices.DEADLINE_CHOICES,
|
||||
initial='OTHER',
|
||||
label=_(u'Anmeldeschluss'),
|
||||
widget=forms.RadioSelect())
|
||||
|
||||
@@ -697,8 +605,6 @@ class RegistrationForm(EventCreateForm):
|
||||
def _proceed_session_data(self, session_data):
|
||||
super(RegistrationForm, self)._proceed_session_data(session_data)
|
||||
|
||||
sport = session_data.get('sport', None)
|
||||
terrain = session_data.get('terrain', None)
|
||||
first_day = session_data.get('first_day', None)
|
||||
trainer_fullname = u'%s %s' % (session_data.get('trainer_firstname'), session_data.get('trainer_familyname'))
|
||||
trainer_email = session_data.get('trainer_email')
|
||||
@@ -738,36 +644,10 @@ class RegistrationForm(EventCreateForm):
|
||||
new_choices.append((key, desc))
|
||||
self.fields['deadline'].choices = new_choices
|
||||
|
||||
registration_howto = _(u'Anmeldung mit Vor- und Nachname, E-Mail-Adresse, Telefonnummer (Mobil)'
|
||||
u'%(additional)s bei %(name)s (%(emailaddr)s).')
|
||||
additional = u''
|
||||
if sport == 'B':
|
||||
additional = u'%s %s' % (_(u', Notfall-Kontakt, DAV-Mitgliedsnummer'),
|
||||
_(u'sowie Beschreibung der eigenen Bergerfahrung'))
|
||||
elif sport == 'K' and terrain == 'alpine':
|
||||
additional = u'%s %s' % (_(u', Notfall-Kontakt, DAV-Mitgliedsnummer'),
|
||||
_(u'sowie Beschreibung der eigenen Fels- bzw. Bergerfahrung'))
|
||||
elif sport == 'K':
|
||||
additional = u'%s %s' % (_(u', DAV-Mitgliedsnummer'),
|
||||
_(u'sowie Beschreibung der eigenen Klettererfahrung'))
|
||||
elif sport == 'M' and terrain == 'alpine':
|
||||
additional = u'%s %s' % (_(u', Notfall-Kontakt, DAV-Mitgliedsnummer'),
|
||||
_(u'sowie kurzer Beschreibung der eigenen MTB-Erfahrung'))
|
||||
elif sport == 'M':
|
||||
additional = u'%s %s' % (_(u', DAV-Mitgliedsnummer'),
|
||||
_(u'sowie kurzer Beschreibung der eigenen MTB-Erfahrung'))
|
||||
elif sport == 'S':
|
||||
additional = u'%s %s' % (_(u', Notfall-Kontakt, DAV-Mitgliedsnummer'),
|
||||
_(u'sowie Beschreibung der eigenen Skitouren- und Bergerfahrung'))
|
||||
elif terrain == 'alpine':
|
||||
additional = _(u', Notfall-Kontakt und DAV-Mitgliedsnummer')
|
||||
else:
|
||||
registration_howto = None
|
||||
|
||||
if registration_howto:
|
||||
self.fields['registration_howto'].initial = registration_howto % {'name': trainer_fullname,
|
||||
'emailaddr': trainer_email,
|
||||
'additional': additional}
|
||||
if self.fields['registration_howto'].initial:
|
||||
initial = self.fields['registration_howto'].initial % {'name': trainer_fullname,
|
||||
'emailaddr': trainer_email}
|
||||
self.fields['registration_howto'].initial = initial
|
||||
else:
|
||||
self.fields['registration_howto'].widget = forms.HiddenInput()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user