2018-06-29 12:00:45 +00:00
|
|
|
from flask_babel import lazy_gettext as _
|
|
|
|
from flask_wtf import FlaskForm
|
2018-06-30 04:44:45 +00:00
|
|
|
from wtforms import PasswordField, StringField, BooleanField
|
|
|
|
from wtforms.ext.dateutil.fields import DateTimeField
|
2018-06-29 12:00:45 +00:00
|
|
|
from wtforms.validators import DataRequired, Email, ValidationError
|
2018-06-30 04:44:45 +00:00
|
|
|
from wtforms.widgets import TextArea
|
2018-06-29 12:00:45 +00:00
|
|
|
|
|
|
|
|
|
|
|
class RegistrationForm(FlaskForm):
|
|
|
|
username = StringField(_('Username'), validators=[DataRequired()])
|
|
|
|
email = StringField(_('Email address'), validators=[Email()])
|
|
|
|
password = PasswordField(_('Password'), validators=[DataRequired()])
|
|
|
|
password_retype = PasswordField(_('Password, once more'), validators=[DataRequired()])
|
|
|
|
|
|
|
|
def validate_password_retype(self, field):
|
|
|
|
if field.data != self.password.data:
|
|
|
|
raise ValidationError(_('The two passwords must match!'))
|
2018-06-30 04:44:45 +00:00
|
|
|
|
|
|
|
|
|
|
|
class EventForm(FlaskForm):
|
|
|
|
title = StringField(_('Title'), validators=[DataRequired()])
|
|
|
|
time_zone = StringField(_('Time zone'), validators=[DataRequired()])
|
|
|
|
start_time = DateTimeField(_('Start time'), validators=[DataRequired()])
|
|
|
|
end_time = DateTimeField(_('End time'), validators=[DataRequired()])
|
|
|
|
all_day = BooleanField(_('All day'))
|
|
|
|
description = StringField(_('Description'), widget=TextArea())
|
|
|
|
|
|
|
|
def validate_end_time(self, field):
|
|
|
|
if field.data < self.start_time.data:
|
|
|
|
raise ValidationError(_('End time must be later than start time!'))
|