Pass field data, not field

This commit is contained in:
richard-dds 2018-10-15 16:39:49 -04:00
parent 4b8585234f
commit 965c5f3e00
2 changed files with 9 additions and 11 deletions

View File

@ -17,12 +17,12 @@ class PENumberValidator(object):
re.X, re.X,
) )
def validate(self, request, field): def validate(self, request, pe_id):
if self._same_as_previous(request, field): if self._same_as_previous(request, pe_id):
return True return True
try: try:
PENumbers.get(field.data) PENumbers.get(pe_id)
except NotFoundError: except NotFoundError:
return False return False
@ -43,14 +43,14 @@ class PENumberValidator(object):
return suggestion return suggestion
return None return None
def _same_as_previous(self, request, field): def _same_as_previous(self, request, pe_id):
return request.pe_number == field.data return request.pe_number == pe_id
class TaskOrderNumberValidator(object): class TaskOrderNumberValidator(object):
def validate(self, field): def validate(self, task_order_number):
try: try:
TaskOrders.get(field.data) TaskOrders.get(task_order_number)
except NotFoundError: except NotFoundError:
return False return False

View File

@ -92,7 +92,7 @@ class UpdateFinancialVerification(object):
if not form.validate(): if not form.validate():
should_update = False should_update = False
if not self.pe_validator.validate(self.request, form.pe_id): if not self.pe_validator.validate(self.request, form.pe_id.data):
suggestion = self.pe_validator.suggest_pe_id(form.pe_id.data) suggestion = self.pe_validator.suggest_pe_id(form.pe_id.data)
error_str = ( error_str = (
"We couldn't find that PE number. {}" "We couldn't find that PE number. {}"
@ -102,7 +102,7 @@ class UpdateFinancialVerification(object):
form.pe_id.errors += (error_str,) form.pe_id.errors += (error_str,)
should_submit = False should_submit = False
if not self.task_order_validator.validate(form.task_order_number): if not self.task_order_validator.validate(form.task_order_number.data):
form.task_order_number.errors += ("Task Order number not found",) form.task_order_number.errors += ("Task Order number not found",)
should_submit = False should_submit = False
@ -155,8 +155,6 @@ def update_financial_verification(request_id):
fv_data = http_request.form fv_data = http_request.form
is_extended = http_request.args.get("extended") is_extended = http_request.args.get("extended")
import ipdb; ipdb.set_trace()
try: try:
response_context = UpdateFinancialVerification( response_context = UpdateFinancialVerification(
PENumberValidator(), PENumberValidator(),