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(
|
||||
translate("forms.task_order.oversight_dod_id_label"),
|
||||
validators=[
|
||||
RequiredIf(lambda form: not form._fields.get("am_cor").data),
|
||||
RequiredIf(lambda form: form._fields.get("cor_invite").data),
|
||||
RequiredIf(
|
||||
lambda form: not form._fields.get("am_cor").data
|
||||
and form._fields.get("cor_invite").data
|
||||
),
|
||||
Length(min=10),
|
||||
IsNumber(),
|
||||
],
|
||||
|
@ -80,19 +80,19 @@ def ListItemsUnique(message=translate("forms.validators.list_items_unique_messag
|
||||
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
|
||||
has a truthy value
|
||||
Args:
|
||||
other_field_value (function): calling this on form results in
|
||||
the boolean value of another field that we want to check against;
|
||||
criteria_function (function): calling this function on form results
|
||||
in a boolean value that we want to check against;
|
||||
if it's True, we require the field
|
||||
message (str): an optional message to display if the field is
|
||||
required but hasNone value
|
||||
"""
|
||||
|
||||
def _required_if(form, field):
|
||||
if other_field(form):
|
||||
if criteria_function(form):
|
||||
if field.data is None:
|
||||
raise ValidationError(message)
|
||||
else:
|
||||
|
@ -81,9 +81,11 @@ class ShowTaskOrderWorkflow:
|
||||
elif self._section["section"] == "oversight":
|
||||
if self.user.dod_id == self.task_order.cor_dod_id:
|
||||
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
|
||||
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
|
||||
|
||||
else:
|
||||
|
Loading…
x
Reference in New Issue
Block a user