Fixes a bug where the CLIN type was not displaying correctly for saved

TOs.

The enum for the CLIN type needs to be coerced in the form data so that
the `jedi_clin_field` data is the value of the enum option. Perviously
the `jedi_clin_field` was being populated with a stringified
representation of the enum, like `JEDICLINType.JEDI_CLIN_1`.
This commit is contained in:
dandds
2019-06-18 11:29:38 -04:00
parent 632cd82398
commit c4d8067f45
5 changed files with 25 additions and 4 deletions

View File

@@ -18,8 +18,18 @@ from atst.forms.validators import FileLength
from atst.utils.localization import translate
def coerce_enum(enum_inst):
if getattr(enum_inst, "value", None):
return enum_inst.value
else:
return enum_inst
class CLINForm(FlaskForm):
jedi_clin_type = SelectField("CLIN type", choices=JEDI_CLIN_TYPES)
jedi_clin_type = SelectField(
"CLIN type", choices=JEDI_CLIN_TYPES, coerce=coerce_enum
)
number = StringField(label="CLIN", validators=[Required()])
start_date = DateField(
translate("forms.task_order.start_date_label"),

View File

@@ -8,7 +8,7 @@ from .application_invitation import ApplicationInvitation
from .application_role import ApplicationRole, Status as ApplicationRoleStatus
from .attachment import Attachment
from .audit_event import AuditEvent
from .clin import CLIN
from .clin import CLIN, JEDICLINType
from .environment import Environment
from .environment_role import EnvironmentRole, CSPRole
from .notification_recipient import NotificationRecipient

View File

@@ -14,7 +14,7 @@ def render_task_orders_edit(portfolio_id=None, task_order_id=None, form=None):
if task_order_id:
task_order = TaskOrders.get(task_order_id)
portfolio_id = task_order.portfolio_id
render_args["form"] = form or TaskOrderForm(**task_order.to_dictionary())
render_args["form"] = form or TaskOrderForm(obj=task_order)
render_args["task_order_id"] = task_order_id
render_args["task_order"] = task_order
else: