Varia library working group XPPL. https://gitea.xpub.nl/XPUB/XPPL
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

113 lines
3.9 KiB

6 years ago
from flask_wtf import FlaskForm
from wtforms import FieldList, FileField
from wtforms import Form as NoCsrfForm
from wtforms import validators
from wtforms.fields import FormField, SelectField, StringField, SubmitField
from wtforms.fields.html5 import DecimalRangeField
from wtforms.validators import DataRequired, InputRequired
from xppl.models import 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()])
6 years ago
6 years ago
class UploadForm(FlaskForm):
6 years ago
title = StringField('title', validators=[InputRequired()])
author = FieldList(
FormField(AuthorForm, default=lambda: Author()),
min_entries=1
)
6 years ago
category = StringField('category', validators=[InputRequired()])
year_published = StringField(
'year published',
[validators.Length(max=4)],
default=None
)
6 years ago
file = FileField()
6 years ago
upload = SubmitField(label='Upload')
wish = SubmitField(label='''I don't have the file, but wish I did.''')
message = StringField('message', default=None)
sameness = DecimalRangeField('sameness', default=0)
diversity = DecimalRangeField('diversity', default=0)
gender = DecimalRangeField('gender', default=50)
choices = [('Student', 'Student'),
('Librarian', 'Librarian'),
('Pirate', 'Pirate'),
('Teacher', 'Teacher'),
('Institution', 'Institution'),
('All of the above', 'All of the above'),
('None of the above', 'None of the above')]
who = SelectField('', choices=choices, default='Student')
6 years ago
class EditForm(FlaskForm):
title = StringField('title', validators=[InputRequired()])
author = FieldList(
FormField(AuthorForm, default=lambda: Author()),
min_entries=1
)
6 years ago
category = StringField('category', validators=[InputRequired()])
year_published = StringField(
'year published',
[validators.Length(max=4)],
default=None
)
file = FileField()
message = StringField('message')
sameness = DecimalRangeField('sameness', default=0)
diversity = DecimalRangeField('diversity', default=0)
gender = DecimalRangeField('gender', default=50)
choices = [('Student', 'Student'),
('Librarian', 'Librarian'),
('Pirate', 'Pirate'),
('Teacher', 'Teacher'),
('Institution', 'Institution'),
('All of the above', 'All of the above'),
('None of the above', 'None of the above')]
who = SelectField('', choices=choices, default='Student')
6 years ago
class ChatForm(FlaskForm):
message = StringField('message', validators=[InputRequired()])
send = SubmitField(label='Send')
6 years ago
class StackForm(FlaskForm):
stack_name = StringField('Stack', validators=[InputRequired()])
stack_description = StringField(
'Description',
validators=[InputRequired()]
)
stack_author = StringField('Who made this', validators=[InputRequired()])
6 years ago
create = SubmitField(label='Create')
6 years ago
class AddtoStackForm(FlaskForm):
6 years ago
select_stack = SelectField('Stacks', validators=[InputRequired()])
class EditStackForm(FlaskForm):
edit_stack_name = StringField('Stack', validators=[InputRequired()])
edit_stack_description = StringField(
'Description',
validators=[InputRequired()]
)
6 years ago
class SearchForm(FlaskForm):
choices = [('All', 'All'),
('Title', 'Title'),
('Author', 'Author'),
('Category', 'Category'),
('Stack', 'Stack'),
('Outliers', 'Outliers')]
select = SelectField('', choices=choices, default='All')
6 years ago
search = StringField('', validators=[InputRequired()])
grid = SubmitField('Grid')
listview = SubmitField('List')
randomize = SubmitField('Order differently')