forms.py 1.3 KB

1234567891011121314151617181920212223242526272829303132333435
  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-05-20 18:08:44 (CST)
  9. # Last Update:星期二 2016-7-26 17:27:30 (CST)
  10. # By:
  11. # Description:
  12. # **************************************************************************
  13. from flask_wtf import Form
  14. from wtforms import StringField, TextAreaField, SelectField
  15. from wtforms.validators import DataRequired, Length
  16. from flask_babelex import lazy_gettext as _
  17. from maple.forums.models import Board
  18. class TopicForm(Form):
  19. title = StringField(_('Title:'), [DataRequired(), Length(min=4, max=36)])
  20. content = TextAreaField(_('Content:'), [DataRequired(), Length(min=6)])
  21. category = SelectField(
  22. _('Category:'),
  23. choices=[(b.id, b.board + ' --' + b.parent_board)
  24. for b in Board.query.all()],
  25. coerce=int)
  26. tags = StringField(_('Tags:'), [DataRequired(), Length(min=2, max=36)])
  27. choice = SelectField('choice',
  28. choices=[(1, 'Markdown'), (2, 'Default')],
  29. coerce=int)
  30. class ReplyForm(Form):
  31. content = TextAreaField(_('Content:'), [DataRequired()])