Factor out _raise
This commit is contained in:
parent
0d9c03b54f
commit
8c9488229c
@ -44,6 +44,10 @@ class FinancialVerificationBase(object):
|
|||||||
def _apply_task_order_number_error(self, field):
|
def _apply_task_order_number_error(self, field):
|
||||||
field.errors += ("Task Order number not found",)
|
field.errors += ("Task Order number not found",)
|
||||||
|
|
||||||
|
def _raise(self, form):
|
||||||
|
form.reset()
|
||||||
|
raise FormValidationError(form)
|
||||||
|
|
||||||
|
|
||||||
class GetFinancialVerificationForm(FinancialVerificationBase):
|
class GetFinancialVerificationForm(FinancialVerificationBase):
|
||||||
def __init__(self, user, request, is_extended=False):
|
def __init__(self, user, request, is_extended=False):
|
||||||
@ -98,8 +102,7 @@ class UpdateFinancialVerification(FinancialVerificationBase):
|
|||||||
self.request.id, form.data
|
self.request.id, form.data
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
form.reset()
|
self._raise(form)
|
||||||
raise FormValidationError(form)
|
|
||||||
|
|
||||||
if should_submit:
|
if should_submit:
|
||||||
updated_request = Requests.submit_financial_verification(updated_request)
|
updated_request = Requests.submit_financial_verification(updated_request)
|
||||||
@ -107,8 +110,7 @@ class UpdateFinancialVerification(FinancialVerificationBase):
|
|||||||
workspace = Requests.approve_and_create_workspace(updated_request)
|
workspace = Requests.approve_and_create_workspace(updated_request)
|
||||||
submitted = True
|
submitted = True
|
||||||
else:
|
else:
|
||||||
form.reset()
|
self._raise(form)
|
||||||
raise FormValidationError(form)
|
|
||||||
|
|
||||||
if submitted:
|
if submitted:
|
||||||
return {
|
return {
|
||||||
@ -142,8 +144,7 @@ class SaveFinancialVerificationDraft(FinancialVerificationBase):
|
|||||||
valid = True
|
valid = True
|
||||||
|
|
||||||
if not form.validate_draft():
|
if not form.validate_draft():
|
||||||
form.reset()
|
self._raise(form)
|
||||||
raise FormValidationError(form)
|
|
||||||
|
|
||||||
if form.pe_id.data and not self.pe_validator.validate(
|
if form.pe_id.data and not self.pe_validator.validate(
|
||||||
self.request, form.pe_id.data
|
self.request, form.pe_id.data
|
||||||
@ -164,8 +165,7 @@ class SaveFinancialVerificationDraft(FinancialVerificationBase):
|
|||||||
if valid:
|
if valid:
|
||||||
return {"request": updated_request}
|
return {"request": updated_request}
|
||||||
else:
|
else:
|
||||||
form.reset()
|
self._raise(form)
|
||||||
raise FormValidationError(form)
|
|
||||||
|
|
||||||
|
|
||||||
@requests_bp.route("/requests/verify/<string:request_id>", methods=["GET"])
|
@requests_bp.route("/requests/verify/<string:request_id>", methods=["GET"])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user