clean (alt_)last_day if set to same value as (alt_)first_day.
This commit is contained in:
@@ -209,6 +209,16 @@ class ModeForm(EventCreateForm):
|
||||
return 'TrainingForm'
|
||||
return super(ModeForm, self).next_form_name
|
||||
|
||||
def clean(self):
|
||||
cleaned_data = super(ModeForm, self).clean()
|
||||
last_day = cleaned_data.get('last_day', None)
|
||||
if last_day and last_day == cleaned_data.get('first_day', None):
|
||||
cleaned_data['last_day'] = ''
|
||||
alt_last_day = cleaned_data.get('alt_last_day', None)
|
||||
if alt_last_day and alt_last_day == cleaned_data.get('alt_first_day', None):
|
||||
cleaned_data['alt_last_day'] = ''
|
||||
return cleaned_data
|
||||
|
||||
|
||||
class TrainingForm(EventCreateForm):
|
||||
_form_title = _(u'Kursinhalte / Kursziele')
|
||||
@@ -478,41 +488,42 @@ class DescriptionForm(EventCreateForm):
|
||||
description = forms.CharField(label=_(u'Beschreibung'),
|
||||
widget=forms.Textarea(attrs={'rows': 5}))
|
||||
|
||||
def _proceed_session_data(self, session_data):
|
||||
super(DescriptionForm, self)._proceed_session_data(session_data)
|
||||
def get_initial_for_field(self, field, field_name):
|
||||
if field_name == 'title':
|
||||
mode = self._session_data.get('mode', None)
|
||||
sport = self._session_data.get('sport', None)
|
||||
level = self._session_data.get('level', None)
|
||||
terrain = self._session_data.get('terrain', None)
|
||||
last_day = self._session_data.get('last_day', None)
|
||||
|
||||
mode = session_data.get('mode', None)
|
||||
sport = session_data.get('sport', None)
|
||||
level = session_data.get('level', None)
|
||||
terrain = session_data.get('terrain', None)
|
||||
last_day = session_data.get('last_day', None)
|
||||
value = u''
|
||||
if mode == 'training':
|
||||
if level == 'beginner':
|
||||
value += u'%s ' % ugettext(u'Grundkurs')
|
||||
else:
|
||||
value += u'%s ' % ugettext(u'Aufbaukurs')
|
||||
|
||||
title_prefix = u''
|
||||
if mode == 'training':
|
||||
if level == 'beginner':
|
||||
title_prefix += u'%s ' % ugettext(u'Grundkurs')
|
||||
else:
|
||||
title_prefix += u'%s ' % ugettext(u'Aufbaukurs')
|
||||
if sport == 'B':
|
||||
value += u'%s' % ugettext(u'Alpin')
|
||||
elif sport == 'K':
|
||||
if terrain == 'gym':
|
||||
value += ugettext(u'Indoorklettern')
|
||||
elif terrain == 'crag':
|
||||
value += ugettext(u'Fels')
|
||||
elif terrain == 'alpine':
|
||||
value += ugettext(u'Alpinklettern')
|
||||
|
||||
if sport == 'B':
|
||||
title_prefix += u'%s' % ugettext(u'Alpin')
|
||||
elif sport == 'K':
|
||||
if terrain == 'gym':
|
||||
title_prefix += ugettext(u'Indoorklettern')
|
||||
elif terrain == 'crag':
|
||||
title_prefix += ugettext(u'Fels')
|
||||
elif terrain == 'alpine':
|
||||
title_prefix += ugettext(u'Alpinklettern')
|
||||
value += u': ...'
|
||||
elif sport == 'W' and not last_day:
|
||||
value += u'%s ...' % ugettext(u'Tageswanderung')
|
||||
|
||||
title_prefix += u': ...'
|
||||
elif sport == 'W' and not last_day:
|
||||
title_prefix += u'%s ...' % ugettext(u'Tageswanderung')
|
||||
if app_config.settings.forms_development_init:
|
||||
if not value:
|
||||
value = u'%s' % choices.SPORT_CHOICES.get_label(sport)
|
||||
else:
|
||||
value = super(DescriptionForm, self).get_initial_for_field(field, field_name)
|
||||
|
||||
if app_config.settings.forms_development_init:
|
||||
if not title_prefix:
|
||||
title_prefix = u'%s' % choices.SPORT_CHOICES.get_label(sport)
|
||||
|
||||
self.fields['title'].initial = title_prefix
|
||||
return value
|
||||
|
||||
|
||||
class TrainerForm(EventCreateForm):
|
||||
|
||||
Reference in New Issue
Block a user