forms.py 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #*************************************************************************
  2. # Copyright © 2015 JiangLin. All rights reserved.
  3. # File Name: askform.py
  4. # Author:JiangLin
  5. # Mail:xiyang0807@gmail.com
  6. # Created Time: 2015-11-27 17:54:07
  7. #*************************************************************************
  8. #!/usr/bin/env python
  9. # -*- coding=UTF-8 -*-
  10. from flask_wtf import Form
  11. from wtforms import StringField, TextAreaField, SelectField
  12. from maple.forms.forms import DataRequired, Length
  13. from flask_wtf.file import FileField, FileAllowed, FileRequired
  14. class QuestionForm(Form):
  15. title = StringField('标题:',
  16. [DataRequired(),
  17. Length(min=4, max=36)])
  18. content = TextAreaField('问题描述:',
  19. [DataRequired(),
  20. Length(min=6)])
  21. choice = SelectField('文本标记语法',
  22. choices=[('Default', 'Default'),
  23. ('Markdown', 'Markdown')])
  24. tags = StringField('节点:',
  25. [DataRequired(),
  26. Length(min=2, max=36)])
  27. class PhotoForm(Form):
  28. photo = FileField('上传图片',
  29. validators=[FileRequired(), FileAllowed(
  30. ['jpg', 'png'], '只能为图片')])
  31. class ReplyForm(Form):
  32. content = TextAreaField('回复:',
  33. [DataRequired(),
  34. Length(min=4)])