2018-05-20 00:10:01 +02:00
|
|
|
from flask_wtf import FlaskForm
|
2018-05-31 20:06:13 +02:00
|
|
|
from wtforms import StringField, FileField, validators
|
2018-05-23 14:12:24 +02:00
|
|
|
from wtforms.validators import InputRequired, DataRequired
|
|
|
|
from wtforms import FieldList
|
|
|
|
from wtforms import Form as NoCsrfForm
|
2018-06-07 23:33:22 +02:00
|
|
|
from wtforms.fields import StringField, FormField, SubmitField, SelectField, RadioField
|
2018-06-03 14:01:59 +02:00
|
|
|
from app.models import Book, BookSchema, Author, Stack, StackSchema
|
2018-05-23 14:12:24 +02:00
|
|
|
|
|
|
|
# - - - 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
|
|
|
|
2018-05-31 18:26:22 +02:00
|
|
|
class UploadForm(FlaskForm):
|
2018-05-20 00:10:01 +02:00
|
|
|
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-06-01 21:37:45 +02:00
|
|
|
year_published = StringField('year published', [validators.Length(max=4)],default=None)
|
2018-05-20 00:10:01 +02:00
|
|
|
file = FileField()
|
2018-05-31 18:26:22 +02:00
|
|
|
upload = SubmitField(label='Upload')
|
|
|
|
wish = SubmitField(label='''I don't have the file, but wish I did.''')
|
2018-06-09 22:05:47 +02:00
|
|
|
message = StringField('message', default=None)
|
2018-05-23 14:12:24 +02:00
|
|
|
|
2018-05-31 18:26:22 +02:00
|
|
|
class EditForm(FlaskForm):
|
2018-05-23 14:12:24 +02:00
|
|
|
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()])
|
2018-06-01 21:37:45 +02:00
|
|
|
year_published = StringField('year published', [validators.Length(max=4)],default=None)
|
2018-06-07 09:59:08 +02:00
|
|
|
file = FileField()
|
2018-06-09 22:05:47 +02:00
|
|
|
message = StringField('message')
|
2018-06-05 18:26:25 +02:00
|
|
|
|
2018-06-03 12:29:08 +02:00
|
|
|
class ChatForm(FlaskForm):
|
|
|
|
message = StringField('message', validators=[InputRequired()])
|
|
|
|
send = SubmitField(label='Send')
|
|
|
|
|
2018-06-03 14:01:59 +02:00
|
|
|
class StackForm(FlaskForm):
|
|
|
|
stack_name = StringField('Stack', validators=[InputRequired()])
|
|
|
|
stack_description = StringField('Description', validators=[InputRequired()])
|
|
|
|
create = SubmitField(label='Create')
|
2018-05-31 18:26:22 +02:00
|
|
|
|
2018-06-03 23:33:16 +02:00
|
|
|
class AddtoStackForm(FlaskForm):
|
2018-06-04 23:40:12 +02:00
|
|
|
select_stack = SelectField('Stacks', validators=[InputRequired()])
|
2018-06-05 18:26:25 +02:00
|
|
|
|
|
|
|
class EditStackForm(FlaskForm):
|
2018-06-06 11:39:38 +02:00
|
|
|
edit_stack_name = StringField('Stack', validators=[InputRequired()])
|
|
|
|
edit_stack_description = StringField('Description', validators=[InputRequired()])
|
2018-06-05 18:26:25 +02:00
|
|
|
|
2018-05-31 18:26:22 +02:00
|
|
|
class SearchForm(FlaskForm):
|
2018-06-03 15:23:10 +02:00
|
|
|
choices = [('All', 'All'),
|
|
|
|
('Title', 'Title'),
|
2018-06-07 10:46:14 +02:00
|
|
|
('Author', 'Author'),
|
|
|
|
('Category', 'Category'),
|
|
|
|
('Stack', 'Stack')]
|
2018-06-07 23:33:22 +02:00
|
|
|
select = SelectField('', choices=choices, default='All')
|
2018-05-31 18:26:22 +02:00
|
|
|
search = StringField('', validators=[InputRequired()])
|
2018-06-07 19:10:56 +02:00
|
|
|
grid = SubmitField('Grid')
|
|
|
|
listview = SubmitField('List')
|
2018-06-07 23:33:22 +02:00
|
|
|
randomize = SubmitField('Order differently')
|
|
|
|
|
|
|
|
|
2018-06-07 19:10:56 +02:00
|
|
|
|
2018-06-07 10:46:14 +02:00
|
|
|
|