forms.py 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. #!/usr/bin/env python
  2. # -*- coding=UTF-8 -*-
  3. # **************************************************************************
  4. # Copyright © 2016 jianglin
  5. # File Name: forms.py
  6. # Author: jianglin
  7. # Email: xiyang0807@gmail.com
  8. # Created: 2016-06-03 19:27:58 (CST)
  9. # Last Update:星期二 2016-7-26 10:38:39 (CST)
  10. # By:
  11. # Description:
  12. # **************************************************************************
  13. from flask_wtf import Form
  14. from wtforms import SelectField, StringField, TextAreaField
  15. from wtforms.validators import DataRequired
  16. from flask_babelex import lazy_gettext as _
  17. class SortForm(Form):
  18. display = SelectField(
  19. _('Choice'),
  20. coerce=int,
  21. choices=[(0, _('All Topics')), (1, _('One Day')), (2, _('One Week')), (
  22. 3, _('One Month'))])
  23. sort = SelectField('Sort',
  24. coerce=int,
  25. choices=[(0, _('Publish')), (1, _('Author'))])
  26. st = SelectField('Up and Down',
  27. coerce=int,
  28. choices=[(0, _('Desc')), (1, _('Asc'))])
  29. class SearchForm(Form):
  30. search = StringField(_('search'), validators=[DataRequired()])
  31. class MessageForm(Form):
  32. message = TextAreaField(_('message'), validators=[DataRequired()])