atst/atst/forms/task_order.py
2019-06-12 15:29:47 -04:00

64 lines
1.8 KiB
Python

from wtforms.fields import (
BooleanField,
DecimalField,
FieldList,
FileField,
FormField,
StringField,
)
from wtforms.fields.html5 import DateField
from wtforms.validators import Required
from flask_wtf.file import FileAllowed
from flask_wtf import FlaskForm
from .data import JEDI_CLIN_TYPES
from .fields import SelectField
from .forms import BaseForm
from atst.forms.validators import FileLength
from atst.utils.localization import translate
class CLINForm(FlaskForm):
jedi_clin_type = SelectField("CLIN type", choices=JEDI_CLIN_TYPES)
number = StringField(label="CLIN", validators=[Required()])
start_date = DateField(
translate("forms.task_order.start_date_label"),
format="%m/%d/%Y",
validators=[Required()],
)
end_date = DateField(
translate("forms.task_order.end_date_label"),
format="%m/%d/%Y",
validators=[Required()],
)
obligated_amount = DecimalField(label="Funds obligated for cloud")
loas = FieldList(StringField())
class UnclassifiedCLINForm(CLINForm):
# TODO: overwrite jedi_clin_type to only include the unclassified options
pass
class TaskOrderForm(BaseForm):
number = StringField(
label=translate("forms.task_order.number_description"),
validators=[Required()],
)
pdf = FileField(
None,
validators=[
FileAllowed(["pdf"], translate("forms.task_order.file_format_not_allowed")),
FileLength(message=translate("forms.validators.file_length")),
],
render_kw={"accept": ".pdf,application/pdf"},
)
clins = FieldList(FormField(CLINForm))
class SignatureForm(BaseForm):
signature = BooleanField(
translate("task_orders.sign.digital_signature_description"),
validators=[Required()],
)