43 lines
1.9 KiB
Python
Executable File
43 lines
1.9 KiB
Python
Executable File
from flask_wtf import FlaskForm
|
|
from wtforms import StringField, FileField, validators
|
|
from wtforms.validators import InputRequired, DataRequired
|
|
from wtforms import FieldList
|
|
from wtforms import Form as NoCsrfForm
|
|
from wtforms.fields import StringField, FormField, SubmitField, SelectField
|
|
from app.models import Book, BookSchema, Author, Stack, StackSchema
|
|
|
|
# - - - Forms - - -
|
|
class AuthorForm(NoCsrfForm):
|
|
# this forms is never exposed so we can user the non CSRF version
|
|
author_name = StringField('Author Name', validators=[DataRequired()])
|
|
|
|
class UploadForm(FlaskForm):
|
|
title = StringField('title', validators=[InputRequired()])
|
|
author = FieldList(FormField(AuthorForm, default=lambda: Author()), min_entries=1)
|
|
category = StringField('category', validators=[InputRequired()])
|
|
year_published = StringField('year published', [validators.Length(max=4)],default=None)
|
|
file = FileField()
|
|
upload = SubmitField(label='Upload')
|
|
wish = SubmitField(label='''I don't have the file, but wish I did.''')
|
|
|
|
class EditForm(FlaskForm):
|
|
title = StringField('title', validators=[InputRequired()])
|
|
author = FieldList(FormField(AuthorForm, default=lambda: Author()), min_entries=1)
|
|
category = StringField('category', validators=[InputRequired()])
|
|
year_published = StringField('year published', [validators.Length(max=4)],default=None)
|
|
class ChatForm(FlaskForm):
|
|
message = StringField('message', validators=[InputRequired()])
|
|
send = SubmitField(label='Send')
|
|
|
|
class StackForm(FlaskForm):
|
|
stack_name = StringField('Stack', validators=[InputRequired()])
|
|
stack_description = StringField('Description', validators=[InputRequired()])
|
|
create = SubmitField(label='Create')
|
|
|
|
class SearchForm(FlaskForm):
|
|
choices = [('All', 'All'),
|
|
('Title', 'Title'),
|
|
('Category', 'Category')]
|
|
select = SelectField('', choices=choices)
|
|
search = StringField('', validators=[InputRequired()])
|