Added locale settings to event creation

This commit is contained in:
Raphael Michel
2016-05-04 18:29:40 +02:00
parent 1efdc1e44f
commit 3ae13ce0ed
4 changed files with 67 additions and 3 deletions

View File

@@ -40,6 +40,29 @@ class EventCreateForm(I18nModelForm):
return slug
class EventCreateSettingsForm(SettingsForm):
timezone = forms.ChoiceField(
choices=((a, a) for a in common_timezones),
label=_("Default timezone"),
)
locales = forms.MultipleChoiceField(
choices=settings.LANGUAGES,
label=_("Available langauges"),
)
locale = forms.ChoiceField(
choices=settings.LANGUAGES,
label=_("Default language"),
)
def clean(self):
data = super().clean()
if data['locale'] not in data['locales']:
raise ValidationError({
'locale': _('Your default locale must also be enebled for your event (see box above).')
})
return data
class EventUpdateForm(I18nModelForm):
def clean_slug(self):
return self.instance.slug