mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2025-07-26 22:01:34 +00:00
Some renaming and moving
This commit is contained in:
@@ -3,4 +3,4 @@ from flask import Blueprint
|
||||
jobs = Blueprint('jobs', __name__)
|
||||
|
||||
|
||||
from . import views
|
||||
from . import forms, views
|
||||
|
67
app/jobs/forms.py
Normal file
67
app/jobs/forms.py
Normal file
@@ -0,0 +1,67 @@
|
||||
from flask_wtf import FlaskForm
|
||||
from wtforms import (BooleanField, MultipleFileField, SelectField, StringField,
|
||||
SubmitField, ValidationError)
|
||||
from wtforms.validators import DataRequired, Length
|
||||
|
||||
|
||||
class AddNLPJobForm(FlaskForm):
|
||||
description = StringField('Description',
|
||||
validators=[DataRequired(), Length(1, 255)])
|
||||
files = MultipleFileField('Files', 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()
|
||||
title = StringField('Title', validators=[DataRequired(), Length(1, 32)])
|
||||
version = SelectField('Version',
|
||||
choices=[('2.1.0', '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'
|
||||
)
|
||||
|
||||
|
||||
class AddOCRJobForm(FlaskForm):
|
||||
binarization = BooleanField('Binarazation')
|
||||
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()])
|
||||
split = BooleanField('Split')
|
||||
submit = SubmitField()
|
||||
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:
|
||||
if not file.filename.lower().endswith(('.pdf', '.tif', '.tiff')):
|
||||
raise ValidationError(
|
||||
'File does not have an approved extension: '
|
||||
'.pdf | .tif | .tiff'
|
||||
)
|
@@ -1,9 +1,9 @@
|
||||
from app.models import Job, JobInput, JobResult
|
||||
from app.utils import background_delete_job
|
||||
from flask import (abort, current_app, flash, redirect, render_template,
|
||||
send_from_directory, url_for)
|
||||
from flask_login import current_user, login_required
|
||||
from . import jobs
|
||||
from ..models import Job, JobInput, JobResult
|
||||
import os
|
||||
import threading
|
||||
|
||||
|
Reference in New Issue
Block a user