Merge pull request #1019 from dod-ccpo/upload-error-handling

Add validations and error states for TO upload form
This commit is contained in:
dandds
2019-08-14 14:30:46 -04:00
committed by GitHub
10 changed files with 102 additions and 43 deletions

View File

@@ -7,7 +7,7 @@ from wtforms.fields import (
HiddenField,
)
from wtforms.fields.html5 import DateField
from wtforms.validators import Required, Optional
from wtforms.validators import Required, Optional, Length
from flask_wtf import FlaskForm
from .data import JEDI_CLIN_TYPES
@@ -65,10 +65,25 @@ class CLINForm(FlaskForm):
class AttachmentForm(BaseForm):
filename = HiddenField(id="attachment_filename")
object_name = HiddenField(id="attachment_object_name")
filename = HiddenField(
id="attachment_filename",
validators=[
Length(max=100, message=translate("forms.attachment.filename.length_error"))
],
)
object_name = HiddenField(
id="attachment_object_name",
validators=[
Length(
max=40, message=translate("forms.attachment.object_name.length_error")
)
],
)
accept = ".pdf,application/pdf"
def validate(self, *args, **kwargs):
return super().validate(*args, **{**kwargs, "flash_invalid": False})
class TaskOrderForm(BaseForm):
number = StringField(label=translate("forms.task_order.number_description"))