forked from gergely/calendar-social
Add user settings with time zones
This commit is contained in:
@@ -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)
|
||||
|
Reference in New Issue
Block a user