diff --git a/app/services/forms.py b/app/services/forms.py index 6ee5683fc0cf42812a4f392387be6e34459b6480..2f4a1b515cf99388715213439b2aa5eaa5cb0a7f 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 8eefa9c51eaccc3536d950e45fd9dbe465410ebf..06e4a961971939c95bc4cff17f28453cda184a81 100644 --- a/app/templates/base.html.j2 +++ b/app/templates/base.html.j2 @@ -182,6 +182,7 @@ <script type="text/javascript" src="{{ url_for('static', filename='js/materialize.min.js') }}"></script> <script> M.AutoInit(); + M.CharacterCounter.init(document.querySelectorAll('input[data-length][type="text"]')) M.Dropdown.init( document.getElementById("nav-notifications"), {"alignment": "right", "constrainWidth": false, "coverTrigger": false} diff --git a/app/templates/services/nlp.html.j2 b/app/templates/services/nlp.html.j2 index 8e394f084a93bb4f47477fc1fc58ca2fa4a2cead..846d888cead08518649a1276c58eac34f4d12955 100644 --- a/app/templates/services/nlp.html.j2 +++ b/app/templates/services/nlp.html.j2 @@ -60,7 +60,7 @@ <div class="col s12 m4"> <div class="input-field"> <i class="material-icons prefix">title</i> - {{ new_nlp_job_form.title() }} + {{ new_nlp_job_form.title(data_length='32') }} {{ new_nlp_job_form.title.label }} {% for error in new_nlp_job_form.title.errors %} <span class="helper-text red-text">{{ error }}</span> @@ -106,7 +106,7 @@ <div class="col s12 m6"> <div class="input-field"> <i class="material-icons prefix">description</i> - {{ new_nlp_job_form.description() }} + {{ new_nlp_job_form.description(data_length='255') }} {{ new_nlp_job_form.description.label }} {% for error in new_nlp_job_form.description.errors %} <span class="helper-text red-text">{{ error }}</span> diff --git a/app/templates/services/ocr.html.j2 b/app/templates/services/ocr.html.j2 index 3e27289814314ac626de7eb8a89e5ed5e5c5e3a4..32f995d74028d5a46ee74af1e7999176b8d21238 100644 --- a/app/templates/services/ocr.html.j2 +++ b/app/templates/services/ocr.html.j2 @@ -61,7 +61,7 @@ <div class="col s12 m4"> <div class="input-field"> <i class="material-icons prefix">title</i> - {{ new_ocr_job_form.title() }} + {{ new_ocr_job_form.title(data_length='32') }} {{ new_ocr_job_form.title.label }} {% for error in new_ocr_job_form.title.errors %} <span class="helper-text red-text">{{ error }}</span> @@ -107,7 +107,7 @@ <div class="col s12 m6"> <div class="input-field"> <i class="material-icons prefix">description</i> - {{ new_ocr_job_form.description() }} + {{ new_ocr_job_form.description(data_length='255') }} {{ new_ocr_job_form.description.label }} {% for error in new_ocr_job_form.description.errors %} <span class="helper-text red-text">{{ error }}</span>