diff --git a/app/auth/forms.py b/app/auth/forms.py index 4a524cfa..02658b62 100644 --- a/app/auth/forms.py +++ b/app/auth/forms.py @@ -1,5 +1,6 @@ from flask_wtf import FlaskForm -from wtforms import StringField, PasswordField, BooleanField, SubmitField, ValidationError, TextAreaField +from wtforms import (StringField, PasswordField, BooleanField, SubmitField, + ValidationError) from wtforms.validators import DataRequired, Length, Email, Regexp, EqualTo from ..models import User @@ -13,13 +14,20 @@ class LoginForm(FlaskForm): class RegistrationForm(FlaskForm): email = StringField('Email', validators=[DataRequired(), Email()]) - username = StringField('Username', validators=[ - DataRequired(), Length(1, 64), - Regexp('^[A-Za-z][A-Za-z0-9_.]*$', 0, - 'Usernames must have only letters, numbers, dots or ' - 'underscores')]) - password = PasswordField('Password', validators=[ - DataRequired(), EqualTo('password2', message='Passwords must match.')]) + username = StringField( + 'Username', + validators=[DataRequired(), + Length(1, 64), + Regexp('^[A-Za-z][A-Za-z0-9_.]*$', + 0, + 'Usernames must have only letters, numbers, dots ' + 'or underscores')] + ) + password = PasswordField( + 'Password', + validators=[DataRequired(), + EqualTo('password2', message='Passwords must match.')] + ) password2 = PasswordField('Confirm password', validators=[DataRequired()]) submit = SubmitField('Register') @@ -79,8 +87,8 @@ class ChangePasswordForm(FlaskForm): class EditProfileForm(FlaskForm): - email = StringField('Change Email', validators=[Length(0, 64), - DataRequired()]) + email = StringField('Change Email', + validators=[Length(0, 254), DataRequired()]) submit = SubmitField('Change Email') def __init__(self, user, *args, **kwargs): diff --git a/app/models.py b/app/models.py index 4474bf03..02c789a1 100644 --- a/app/models.py +++ b/app/models.py @@ -110,7 +110,7 @@ class User(UserMixin, db.Model): # Primary key id = db.Column(db.Integer, primary_key=True) confirmed = db.Column(db.Boolean, default=False) - email = db.Column(db.String(64), unique=True, index=True) + email = db.Column(db.String(254), unique=True, index=True) password_hash = db.Column(db.String(128)) registration_date = db.Column(db.DateTime(), default=datetime.utcnow) role_id = db.Column(db.Integer, db.ForeignKey('roles.id')) diff --git a/app/services/forms.py b/app/services/forms.py index 2f4a1b51..5de8af07 100644 --- a/app/services/forms.py +++ b/app/services/forms.py @@ -1,5 +1,6 @@ from flask_wtf import FlaskForm -from wtforms import MultipleFileField, SelectField, StringField, SubmitField, ValidationError +from wtforms import (BooleanField, MultipleFileField, SelectField, StringField, + SubmitField, ValidationError) from wtforms.validators import DataRequired, Length @@ -34,6 +35,7 @@ class NewNLPJobForm(FlaskForm): class NewOCRJobForm(FlaskForm): + binarization = BooleanField('Binarazation') description = StringField('Description', validators=[DataRequired(), Length(1, 255)]) files = MultipleFileField('Files', validators=[DataRequired()]) @@ -49,6 +51,7 @@ class NewOCRJobForm(FlaskForm): ('por', 'Portuguese'), ('spa', 'Spanish; Castilian')], validators=[DataRequired()]) + split = BooleanField('Split') submit = SubmitField('Submit') title = StringField('Title', validators=[DataRequired(), Length(1, 32)]) version = SelectField('Version', diff --git a/app/services/views.py b/app/services/views.py index 7f624f7d..6d785bfb 100644 --- a/app/services/views.py +++ b/app/services/views.py @@ -62,9 +62,13 @@ def ocr(): mem_mb=8192, n_cores=4, service='ocr', - service_args=json.dumps([ - '-l {}'.format(new_ocr_job_form.language.data), - '--skip-binarisation']), + service_args=json.dumps( + [ + '-l {}'.format(new_ocr_job_form.language.data), + '' if new_ocr_job_form.binarization.data + else '--skip-binarisation' + ] + ), service_version=new_ocr_job_form.version.data, status='preparing', title=new_ocr_job_form.title.data) diff --git a/app/templates/auth/register.html.j2 b/app/templates/auth/register.html.j2 index 19dbcd57..acbaa2be 100644 --- a/app/templates/auth/register.html.j2 +++ b/app/templates/auth/register.html.j2 @@ -13,7 +13,7 @@ {{ form.hidden_tag() }}