mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-11-15 17:25:44 +00:00
22 lines
871 B
Python
22 lines
871 B
Python
|
from flask_wtf import FlaskForm
|
||
|
from werkzeug.utils import secure_filename
|
||
|
from wtforms import FileField, StringField, SubmitField, ValidationError
|
||
|
from wtforms.validators import DataRequired, Length
|
||
|
|
||
|
|
||
|
class AddQueryResultForm(FlaskForm):
|
||
|
'''
|
||
|
Form used to import one result json file.
|
||
|
'''
|
||
|
description = StringField('Description',
|
||
|
validators=[DataRequired(), Length(1, 255)])
|
||
|
file = FileField('File', validators=[DataRequired()])
|
||
|
title = StringField('Title', validators=[DataRequired(), Length(1, 32)])
|
||
|
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)
|