mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-11-15 17:25:44 +00:00
87 lines
2.7 KiB
Python
87 lines
2.7 KiB
Python
from flask_wtf import FlaskForm
|
|
from wtforms import MultipleFileField, SelectField, StringField, SubmitField, ValidationError
|
|
from wtforms.validators import DataRequired, Length
|
|
|
|
|
|
class NewNLPJobForm(FlaskForm):
|
|
description = StringField(
|
|
'Description',
|
|
validators=[DataRequired(), Length(1, 255)]
|
|
)
|
|
files = MultipleFileField('Files', validators=[DataRequired()])
|
|
language = SelectField(
|
|
'Language',
|
|
choices=[('', 'Choose your option'),
|
|
('en', 'English'),
|
|
('fr', 'French'),
|
|
('de', 'German'),
|
|
('it', 'Italian'),
|
|
('pt', 'Portuguese'),
|
|
('es', 'Spanish')
|
|
],
|
|
validators=[DataRequired()]
|
|
)
|
|
submit = SubmitField('Submit')
|
|
title = StringField(
|
|
'Title',
|
|
validators=[DataRequired(), Length(1, 32)]
|
|
)
|
|
version = SelectField(
|
|
'Version',
|
|
choices=[('', 'Choose your option'),
|
|
('latest', 'Latest'),
|
|
],
|
|
validators=[DataRequired()]
|
|
)
|
|
|
|
def validate_files(form, field):
|
|
for file in field.data:
|
|
if not file.filename.lower().endswith('.txt'):
|
|
raise ValidationError(
|
|
'File does not have an approved extension: '
|
|
'.txt'
|
|
)
|
|
|
|
|
|
class NewOCRJobForm(FlaskForm):
|
|
description = StringField(
|
|
'Description',
|
|
validators=[DataRequired(), Length(1, 255)]
|
|
)
|
|
files = MultipleFileField('Files', validators=[DataRequired()])
|
|
language = SelectField(
|
|
'Language',
|
|
choices=[('', 'Choose your option'),
|
|
('eng', 'English'),
|
|
('enm', 'English, Middle (1100-1500)'),
|
|
('fra', 'French'),
|
|
('frm', 'French, Middle (ca. 1400-1600)'),
|
|
('deu', 'German'),
|
|
('frk', 'German Fraktur'),
|
|
('ita', 'Italian'),
|
|
('por', 'Portuguese'),
|
|
('spa', 'Spanish; Castilian')
|
|
],
|
|
validators=[DataRequired()]
|
|
)
|
|
submit = SubmitField('Submit')
|
|
title = StringField(
|
|
'Title',
|
|
validators=[DataRequired(), Length(1, 32)]
|
|
)
|
|
version = SelectField(
|
|
'Version',
|
|
choices=[('', 'Choose your option'),
|
|
('latest', 'Latest'),
|
|
],
|
|
validators=[DataRequired()]
|
|
)
|
|
|
|
def validate_files(form, field):
|
|
for file in field.data:
|
|
if not file.filename.lower().endswith(('.pdf', '.tif', '.tiff')):
|
|
raise ValidationError(
|
|
'File does not have an approved extension: '
|
|
'.pdf | .tif | .tiff'
|
|
)
|