2018-05-20 00:10:01 +02:00
|
|
|
from flask_wtf import FlaskForm
|
|
|
|
from wtforms import StringField, FileField
|
2018-05-23 14:12:24 +02:00
|
|
|
from wtforms.validators import InputRequired, DataRequired
|
|
|
|
from wtforms import FieldList
|
|
|
|
from wtforms import Form as NoCsrfForm
|
|
|
|
from wtforms.fields import StringField, FormField, SubmitField
|
|
|
|
from app.models import Book, BookSchema, Author
|
|
|
|
|
|
|
|
# - - - Forms - - -
|
|
|
|
class AuthorForm(NoCsrfForm):
|
|
|
|
# this forms is never exposed so we can user the non CSRF version
|
|
|
|
author_name = StringField('Author Name', validators=[DataRequired()])
|
2018-05-20 00:10:01 +02:00
|
|
|
|
|
|
|
class UserForm(FlaskForm):
|
|
|
|
title = StringField('title', validators=[InputRequired()])
|
2018-05-23 14:12:24 +02:00
|
|
|
author = FieldList(FormField(AuthorForm, default=lambda: Author()), min_entries=1)
|
2018-05-27 22:11:35 +02:00
|
|
|
category = StringField('category', validators=[InputRequired()])
|
2018-05-20 00:10:01 +02:00
|
|
|
file = FileField()
|
2018-05-23 14:12:24 +02:00
|
|
|
|
|
|
|
class UserForm_Edit(FlaskForm):
|
|
|
|
title = StringField('title', validators=[InputRequired()])
|
|
|
|
author = FieldList(FormField(AuthorForm, default=lambda: Author()), min_entries=1)
|
2018-05-27 22:11:35 +02:00
|
|
|
category = StringField('category', validators=[InputRequired()])
|