Update TO Form to include CLINs and LOAs
This commit is contained in:
parent
9fa4292736
commit
633e1b6a37
@ -221,3 +221,10 @@ ENV_ROLE_NO_ACCESS = "No Access"
|
|||||||
ENV_ROLES = [(role.value, role.value) for role in CSPRole] + [
|
ENV_ROLES = [(role.value, role.value) for role in CSPRole] + [
|
||||||
(ENV_ROLE_NO_ACCESS, "No access")
|
(ENV_ROLE_NO_ACCESS, "No access")
|
||||||
]
|
]
|
||||||
|
|
||||||
|
JEDI_CLIN_TYPES = [
|
||||||
|
("jedi_clin_0001", translate("forms.task_order.clin_01_label")),
|
||||||
|
("jedi_clin_0002", translate("forms.task_order.clin_02_label")),
|
||||||
|
("jedi_clin_0003", translate("forms.task_order.clin_03_label")),
|
||||||
|
("jedi_clin_0004", translate("forms.task_order.clin_04_label")),
|
||||||
|
]
|
||||||
|
@ -1,13 +1,37 @@
|
|||||||
from wtforms.fields import BooleanField, DecimalField, FileField, StringField
|
from wtforms.fields import BooleanField, DecimalField, FieldList, FileField, FormField, StringField
|
||||||
from wtforms.fields.html5 import DateField
|
from wtforms.fields.html5 import DateField
|
||||||
from wtforms.validators import Required, Optional
|
from wtforms.validators import Required, Optional
|
||||||
from flask_wtf.file import FileAllowed
|
from flask_wtf.file import FileAllowed
|
||||||
|
|
||||||
|
from .data import JEDI_CLIN_TYPES
|
||||||
|
from .fields import SelectField
|
||||||
from .forms import BaseForm
|
from .forms import BaseForm
|
||||||
from atst.forms.validators import FileLength
|
from atst.forms.validators import FileLength
|
||||||
from atst.utils.localization import translate
|
from atst.utils.localization import translate
|
||||||
|
|
||||||
|
|
||||||
|
class CLINForm(FlaskForm):
|
||||||
|
jedi_clin_type = SelectField("Jedi CLIN type", choices=JEDI_CLIN_TYPES)
|
||||||
|
clin_number = StringField(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_funds = DecimalField()
|
||||||
|
loas = FieldList(StringField())
|
||||||
|
|
||||||
|
|
||||||
|
class UnclassifiedCLINForm(CLINForm):
|
||||||
|
# TODO: overwrite jedi_clin_type to only include the unclassified options
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class TaskOrderForm(BaseForm):
|
class TaskOrderForm(BaseForm):
|
||||||
number = StringField(
|
number = StringField(
|
||||||
translate("forms.task_order.number_label"),
|
translate("forms.task_order.number_label"),
|
||||||
@ -22,38 +46,7 @@ class TaskOrderForm(BaseForm):
|
|||||||
],
|
],
|
||||||
render_kw={"accept": ".pdf,application/pdf"},
|
render_kw={"accept": ".pdf,application/pdf"},
|
||||||
)
|
)
|
||||||
|
clins = FieldList(FormField(CLINForm))
|
||||||
|
|
||||||
class FundingForm(BaseForm):
|
|
||||||
start_date = DateField(
|
|
||||||
translate("forms.task_order.start_date_label"), format="%m/%d/%Y"
|
|
||||||
)
|
|
||||||
end_date = DateField(
|
|
||||||
translate("forms.task_order.end_date_label"), format="%m/%d/%Y"
|
|
||||||
)
|
|
||||||
clin_01 = DecimalField(
|
|
||||||
translate("forms.task_order.clin_01_label"), validators=[Optional()]
|
|
||||||
)
|
|
||||||
clin_02 = DecimalField(
|
|
||||||
translate("forms.task_order.clin_02_label"), validators=[Optional()]
|
|
||||||
)
|
|
||||||
clin_03 = DecimalField(
|
|
||||||
translate("forms.task_order.clin_03_label"), validators=[Optional()]
|
|
||||||
)
|
|
||||||
clin_04 = DecimalField(
|
|
||||||
translate("forms.task_order.clin_04_label"), validators=[Optional()]
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class UnclassifiedFundingForm(FundingForm):
|
|
||||||
clin_02 = StringField(
|
|
||||||
translate("forms.task_order.unclassified_clin_02_label"),
|
|
||||||
filters=[BaseForm.remove_empty_string],
|
|
||||||
)
|
|
||||||
clin_04 = StringField(
|
|
||||||
translate("forms.task_order.unclassified_clin_04_label"),
|
|
||||||
filters=[BaseForm.remove_empty_string],
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class SignatureForm(BaseForm):
|
class SignatureForm(BaseForm):
|
||||||
|
@ -14,7 +14,7 @@ def render_task_orders_edit(portfolio_id, task_order_id=None, form=None):
|
|||||||
if task_order_id:
|
if task_order_id:
|
||||||
task_order = TaskOrders.get(task_order_id)
|
task_order = TaskOrders.get(task_order_id)
|
||||||
render_args["form"] = form or TaskOrderForm(
|
render_args["form"] = form or TaskOrderForm(
|
||||||
number=task_order.number, pdf=task_order.pdf
|
**task_order.to_dictionary()
|
||||||
)
|
)
|
||||||
render_args["task_order_id"] = task_order_id
|
render_args["task_order_id"] = task_order_id
|
||||||
else:
|
else:
|
||||||
|
@ -33,24 +33,75 @@ def user():
|
|||||||
return UserFactory.create()
|
return UserFactory.create()
|
||||||
|
|
||||||
|
|
||||||
def test_task_orders_new(client, user_session, portfolio):
|
def test_task_orders_edit(client, user_session, portfolio):
|
||||||
user_session(portfolio.owner)
|
user_session(portfolio.owner)
|
||||||
response = client.get(url_for("task_orders.edit", portfolio_id=portfolio.id))
|
response = client.get(url_for("task_orders.edit", portfolio_id=portfolio.id))
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
|
|
||||||
|
|
||||||
def test_task_orders_create(client, user_session, portfolio, pdf_upload, session):
|
def test_task_orders_update(client, user_session, portfolio):
|
||||||
user_session(portfolio.owner)
|
user_session(portfolio.owner)
|
||||||
data = {"number": "0123456789", "pdf": pdf_upload}
|
form_data = {
|
||||||
|
"number": "0123456789",
|
||||||
|
"pdf": pdf_upload,
|
||||||
|
"clins-0-jedi_clin_type": "jedi_clin_0001",
|
||||||
|
"clins-0-clin_number": "12312",
|
||||||
|
"clins-0-start_date": "01/01/2020",
|
||||||
|
"clins-0-end_date": "01/01/2021",
|
||||||
|
"clins-0-obligated_funds": "5000",
|
||||||
|
"clins-0-loas-0-loa": "123123123123",
|
||||||
|
"clins-0-loas-1-loa": "345345234",
|
||||||
|
"clins-1-jedi_clin_type": "jedi_clin_0001",
|
||||||
|
"clins-1-clin_number": "12312",
|
||||||
|
"clins-1-start_date": "01/01/2020",
|
||||||
|
"clins-1-end_date": "01/01/2021",
|
||||||
|
"clins-1-obligated_funds": "5000",
|
||||||
|
"clins-1-loas-0-loa": "78979087",
|
||||||
|
}
|
||||||
response = client.post(
|
response = client.post(
|
||||||
url_for("task_orders.update", portfolio_id=portfolio.id), data=data
|
url_for("task_orders.update", portfolio_id=portfolio.id), data=form_data
|
||||||
)
|
)
|
||||||
assert response.status_code == 302
|
assert response.status_code == 302
|
||||||
task_order = session.query(TaskOrder).filter_by(number=data["number"]).one()
|
task_order = session.query(TaskOrder).filter_by(number=data["number"]).one()
|
||||||
assert task_order.pdf.filename == pdf_upload.filename
|
assert task_order.pdf.filename == pdf_upload.filename
|
||||||
|
|
||||||
|
|
||||||
def test_task_orders_create_invalid_data(client, user_session, portfolio):
|
def test_task_orders_edit_existing_to(client, user_session, task_order):
|
||||||
|
user_session(task_order.creator)
|
||||||
|
response = client.get(
|
||||||
|
url_for(
|
||||||
|
"task_orders.edit",
|
||||||
|
portfolio_id=task_order.portfolio_id,
|
||||||
|
task_order_id=task_order.id,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
assert response.status_code == 200
|
||||||
|
|
||||||
|
|
||||||
|
def test_task_orders_update_existing_to(client, user_session, task_order):
|
||||||
|
user_session(task_order.creator)
|
||||||
|
form_data = {
|
||||||
|
"number": "0123456789",
|
||||||
|
"clins-0-jedi_clin_type": "jedi_clin_0001",
|
||||||
|
"clins-0-clin_number": "12312",
|
||||||
|
"clins-0-start_date": "01/01/2020",
|
||||||
|
"clins-0-end_date": "01/01/2021",
|
||||||
|
"clins-0-obligated_funds": "5000",
|
||||||
|
"clins-0-loas-0-loa": "123123123123",
|
||||||
|
}
|
||||||
|
response = client.post(
|
||||||
|
url_for(
|
||||||
|
"task_orders.update",
|
||||||
|
portfolio_id=task_order.portfolio_id,
|
||||||
|
task_order_id=task_order.id,
|
||||||
|
),
|
||||||
|
data=form_data,
|
||||||
|
)
|
||||||
|
assert response.status_code == 302
|
||||||
|
assert task_order.number == "0123456789"
|
||||||
|
|
||||||
|
|
||||||
|
def test_task_orders_update_invalid_data(client, user_session, portfolio):
|
||||||
user_session(portfolio.owner)
|
user_session(portfolio.owner)
|
||||||
num_task_orders = len(portfolio.task_orders)
|
num_task_orders = len(portfolio.task_orders)
|
||||||
response = client.post(
|
response = client.post(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user