class TransactionCreateForm(Form): description = TextField(u"Beschreibung", validators=[DataRequired()]) valid_on = DateField(u"Gültig ab", validators=[Optional()], today_btn=True, today_highlight=True, default=datetime.date.today()) splits = FieldList(FormField(SplitCreateForm), validators=[DataRequired()], min_entries=2) def validate_splits(self, field): balance = sum(split_form['amount'].data for split_form in field if split_form['amount'].data is not None) if balance != 0: raise ValidationError(u"Buchung ist nicht ausgeglichen.")
class UserSuspendForm(Form): ends_at = FormField(OptionallyUnlimitedEndDateForm) reason = TextAreaField(u"Grund", [DataRequired()]) violation = BooleanField("Verstoß")
class UserEditGroupMembership(Form): begins_at = DateField(u"Beginn", [DataRequired()]) ends_at = FormField(OptionallyUnlimitedEndDateForm)
class UserAddGroupMembership(Form): group = QuerySelectField(u"Gruppe", get_label='name', query_factory=group_query) begins_at = FormField(OptionallyDirectBeginDateForm) ends_at = FormField(OptionallyUnlimitedEndDateForm)