Minor logic and naming fixes
This commit is contained in:
parent
d51663e075
commit
62a3d89484
@ -140,8 +140,10 @@ class OversightForm(CacheableForm):
|
|||||||
cor_dod_id = StringField(
|
cor_dod_id = StringField(
|
||||||
translate("forms.task_order.oversight_dod_id_label"),
|
translate("forms.task_order.oversight_dod_id_label"),
|
||||||
validators=[
|
validators=[
|
||||||
RequiredIf(lambda form: not form._fields.get("am_cor").data),
|
RequiredIf(
|
||||||
RequiredIf(lambda form: form._fields.get("cor_invite").data),
|
lambda form: not form._fields.get("am_cor").data
|
||||||
|
and form._fields.get("cor_invite").data
|
||||||
|
),
|
||||||
Length(min=10),
|
Length(min=10),
|
||||||
IsNumber(),
|
IsNumber(),
|
||||||
],
|
],
|
||||||
|
@ -80,19 +80,19 @@ def ListItemsUnique(message=translate("forms.validators.list_items_unique_messag
|
|||||||
return _list_items_unique
|
return _list_items_unique
|
||||||
|
|
||||||
|
|
||||||
def RequiredIf(other_field, message=translate("forms.validators.is_required")):
|
def RequiredIf(criteria_function, message=translate("forms.validators.is_required")):
|
||||||
""" A validator which makes a field required only if another field
|
""" A validator which makes a field required only if another field
|
||||||
has a truthy value
|
has a truthy value
|
||||||
Args:
|
Args:
|
||||||
other_field_value (function): calling this on form results in
|
criteria_function (function): calling this function on form results
|
||||||
the boolean value of another field that we want to check against;
|
in a boolean value that we want to check against;
|
||||||
if it's True, we require the field
|
if it's True, we require the field
|
||||||
message (str): an optional message to display if the field is
|
message (str): an optional message to display if the field is
|
||||||
required but hasNone value
|
required but hasNone value
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def _required_if(form, field):
|
def _required_if(form, field):
|
||||||
if other_field(form):
|
if criteria_function(form):
|
||||||
if field.data is None:
|
if field.data is None:
|
||||||
raise ValidationError(message)
|
raise ValidationError(message)
|
||||||
else:
|
else:
|
||||||
|
@ -81,9 +81,11 @@ class ShowTaskOrderWorkflow:
|
|||||||
elif self._section["section"] == "oversight":
|
elif self._section["section"] == "oversight":
|
||||||
if self.user.dod_id == self.task_order.cor_dod_id:
|
if self.user.dod_id == self.task_order.cor_dod_id:
|
||||||
self._form.am_cor.data = True
|
self._form.am_cor.data = True
|
||||||
if self.task_order.ko_dod_id:
|
if self.task_order.contracting_officer:
|
||||||
self._form.ko_invite.data = True
|
self._form.ko_invite.data = True
|
||||||
if self.task_order.so_dod_id:
|
if self.task_order.contracting_officer_representative:
|
||||||
|
self._form.cor_invite.data = True
|
||||||
|
if self.task_order.security_officer:
|
||||||
self._form.so_invite.data = True
|
self._form.so_invite.data = True
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user