Add user settings with time zones

This commit is contained in:
2018-07-03 13:15:17 +02:00
parent d07e34a182
commit bba44a3c7f
4 changed files with 64 additions and 0 deletions

View File

@@ -135,3 +135,27 @@ class EventForm(FlaskForm):
if field.data < self.start_time.data:
raise ValidationError(_('End time must be later than start time!'))
class SettingsForm(FlaskForm):
"""Form for user settings
"""
timezone = TimezoneField(_('Time zone'), validators=[DataRequired()])
def __init__(self, user, *args, **kwargs):
self.user = user
kwargs.setdefault('timezone', user.timezone)
FlaskForm.__init__(self, *args, **kwargs)
def populate_obj(self, user):
"""Populate ``obj`` with event data
"""
for name, field in self._fields.items():
if not (hasattr(self.__class__, name) and not hasattr(FlaskForm, name)):
continue
user.settings[name] = str(field.data)