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:
@@ -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"),
|
||||
|
@@ -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
|
||||
|
@@ -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:
|
||||
|
Reference in New Issue
Block a user