From 16fad5bb2d4167ae9e0bb7552b138f5a723cb5e1 Mon Sep 17 00:00:00 2001
From: Patrick Jentsch
Date: Thu, 12 Sep 2019 11:12:59 +0200
Subject: [PATCH] Add character counter to job forms.
---
app/services/forms.py | 93 ++++++++++++------------------
app/templates/base.html.j2 | 1 +
app/templates/services/nlp.html.j2 | 4 +-
app/templates/services/ocr.html.j2 | 4 +-
4 files changed, 42 insertions(+), 60 deletions(-)
diff --git a/app/services/forms.py b/app/services/forms.py
index 6ee5683f..2f4a1b51 100644
--- a/app/services/forms.py
+++ b/app/services/forms.py
@@ -4,75 +4,56 @@ from wtforms.validators import DataRequired, Length
class NewNLPJobForm(FlaskForm):
- description = StringField(
- 'Description',
- validators=[DataRequired(), Length(1, 255)]
- )
+ 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()]
- )
+ language = SelectField('Language',
+ choices=[('', 'Choose your option'),
+ ('nl', 'Dutch'),
+ ('en', 'English'),
+ ('fr', 'French'),
+ ('de', 'German'),
+ ('el', 'Greek'),
+ ('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 (2.1.0)'),
- ('2.1.0', '2.1.0')],
- validators=[DataRequired()]
- )
+ title = StringField('Title', validators=[DataRequired(), Length(1, 32)])
+ version = SelectField('Version',
+ choices=[('latest', 'Latest (2.1.0)'),
+ ('2.1.0', '2.1.0')],
+ 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'
+ 'File does not have an approved extension: .txt'
)
class NewOCRJobForm(FlaskForm):
- description = StringField(
- 'Description',
- validators=[DataRequired(), Length(1, 255)]
- )
+ 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()]
- )
+ 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()]
- )
+ title = StringField('Title', validators=[DataRequired(), Length(1, 32)])
+ version = SelectField('Version',
+ choices=[('latest', 'Latest')],
+ validators=[DataRequired()])
def validate_files(form, field):
for file in field.data:
diff --git a/app/templates/base.html.j2 b/app/templates/base.html.j2
index 8eefa9c5..06e4a961 100644
--- a/app/templates/base.html.j2
+++ b/app/templates/base.html.j2
@@ -182,6 +182,7 @@