Add a docstring to new validator
This commit is contained in:
@@ -81,6 +81,15 @@ def ListItemsUnique(message=translate("forms.validators.list_items_unique_messag
|
||||
|
||||
|
||||
def RequiredIfNot(other_field_name, message=translate("forms.validators.is_required")):
|
||||
""" A validator which makes a field required only if another field
|
||||
has a falsy value
|
||||
Args:
|
||||
other_field_name (str): the name of the field we check before
|
||||
determining if this field is required; if this other field is falsy,
|
||||
the field will be required
|
||||
message (str): an optional message to display if the field is
|
||||
required but hasNone value
|
||||
"""
|
||||
def _required_if_not(form, field):
|
||||
other_field = form._fields.get(other_field_name)
|
||||
if other_field is None:
|
||||
|
@@ -154,7 +154,7 @@ class UpdateTaskOrderWorkflow(ShowTaskOrderWorkflow):
|
||||
if "portfolio_name" in self.form.data:
|
||||
new_name = self.form.data["portfolio_name"]
|
||||
old_name = self.task_order.portfolio_name
|
||||
if not new_name is old_name:
|
||||
if not new_name == old_name:
|
||||
Portfolios.update(self.task_order.portfolio, {"name": new_name})
|
||||
TaskOrders.update(self.user, self.task_order, **self.task_order_form_data)
|
||||
else:
|
||||
|
Reference in New Issue
Block a user