new form field for CLIN numbers to handle when data is zero
This commit is contained in:
dandds 2018-10-01 16:38:39 -04:00 committed by GitHub
commit 19d939578c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 8 deletions

View File

@ -1,4 +1,4 @@
from wtforms.fields import Field, SelectField as SelectField_
from wtforms.fields import Field, StringField, SelectField as SelectField_
from wtforms.widgets import TextArea
@ -31,3 +31,11 @@ class SelectField(SelectField_):
render_kw = kwargs.get("render_kw", {})
kwargs["render_kw"] = {**render_kw, "required": False}
super().__init__(*args, **kwargs)
class NumberStringField(StringField):
def process_data(self, value):
if isinstance(value, int):
self.data = str(value)
else:
self.data = value

View File

@ -9,7 +9,7 @@ from atst.domain.exceptions import NotFoundError
from atst.domain.pe_numbers import PENumbers
from atst.domain.task_orders import TaskOrders
from .fields import NewlineListField, SelectField
from .fields import NewlineListField, SelectField, NumberStringField
from .forms import ValidatedForm
from .data import FUNDING_TYPES
from .validators import DateRange
@ -181,42 +181,42 @@ class ExtendedFinancialForm(BaseFinancialForm):
format="%m/%d/%Y",
)
clin_0001 = StringField(
clin_0001 = NumberStringField(
"<dl><dt>CLIN 0001</dt> - <dd>Unclassified IaaS and PaaS Amount</dd></dl>",
validators=[InputRequired()],
description="Review your task order document, the amounts for each CLIN must match exactly here",
filters=[number_to_int],
)
clin_0003 = StringField(
clin_0003 = NumberStringField(
"<dl><dt>CLIN 0003</dt> - <dd>Unclassified Cloud Support Package</dd></dl>",
validators=[InputRequired()],
description="Review your task order document, the amounts for each CLIN must match exactly here",
filters=[number_to_int],
)
clin_1001 = StringField(
clin_1001 = NumberStringField(
"<dl><dt>CLIN 1001</dt> - <dd>Unclassified IaaS and PaaS Amount <br> OPTION PERIOD 1</dd></dl>",
validators=[InputRequired()],
description="Review your task order document, the amounts for each CLIN must match exactly here",
filters=[number_to_int],
)
clin_1003 = StringField(
clin_1003 = NumberStringField(
"<dl><dt>CLIN 1003</dt> - <dd>Unclassified Cloud Support Package <br> OPTION PERIOD 1</dd></dl>",
validators=[InputRequired()],
description="Review your task order document, the amounts for each CLIN must match exactly here",
filters=[number_to_int],
)
clin_2001 = StringField(
clin_2001 = NumberStringField(
"<dl><dt>CLIN 2001</dt> - <dd>Unclassified IaaS and PaaS Amount <br> OPTION PERIOD 2</dd></dl>",
validators=[InputRequired()],
description="Review your task order document, the amounts for each CLIN must match exactly here",
filters=[number_to_int],
)
clin_2003 = StringField(
clin_2003 = NumberStringField(
"<dl><dt>CLIN 2003</dt> - <dd>Unclassified Cloud Support Package <br> OPTION PERIOD 2</dd></dl>",
validators=[InputRequired()],
description="Review your task order document, the amounts for each CLIN must match exactly here",