mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-11-15 09:15:41 +00:00
19 lines
652 B
Python
19 lines
652 B
Python
from flask_wtf import FlaskForm
|
|
from werkzeug.utils import secure_filename
|
|
from wtforms import FileField, SubmitField, ValidationError
|
|
from wtforms.validators import DataRequired
|
|
|
|
|
|
class ImportResultsForm(FlaskForm):
|
|
'''
|
|
Form used to import one result json file.
|
|
'''
|
|
file = FileField('File', validators=[DataRequired()])
|
|
submit = SubmitField()
|
|
|
|
def validate_file(self, field):
|
|
if not field.data.filename.lower().endswith('.json'):
|
|
raise ValidationError('File does not have an approved extension: '
|
|
'.json')
|
|
field.data.filename = secure_filename(field.data.filename)
|