Converted all form pages. Flow still not working

This commit is contained in:
richard-dds
2018-08-02 10:36:25 -04:00
parent f15fc19eaf
commit a032ccd5b0
6 changed files with 65 additions and 62 deletions

View File

@@ -36,7 +36,6 @@ def suggest_pe_id(pe_id):
return None
@tornado.gen.coroutine
def validate_pe_id(field, existing_request, pe_numbers_repo):
try:
pe_number = pe_numbers_repo.get(field.data)
@@ -55,12 +54,11 @@ def validate_pe_id(field, existing_request, pe_numbers_repo):
class FinancialForm(ValidatedForm):
@tornado.gen.coroutine
def perform_extra_validation(self, existing_request, pe_numbers_repo):
valid = True
if not existing_request or existing_request.get('pe_id') != self.pe_id.data:
valid = yield validate_pe_id(self.pe_id, existing_request, pe_numbers_repo)
raise Return(valid)
return valid
task_order_id = StringField(
"Task Order Number associated with this request.", validators=[Required()]

View File

@@ -5,8 +5,7 @@ from flask_wtf import FlaskForm
class ValidatedForm(FlaskForm):
@tornado.gen.coroutine
def perform_extra_validation(self, *args, **kwargs):
"""A coroutine that performs any applicable extra validation. Must
"""Performs any applicable extra validation. Must
return True if the form is valid or False otherwise."""
raise Return(True)
return True

View File

@@ -63,7 +63,7 @@ def requests_form_update(screen=1, request_id=None):
@requests_bp.route("/requests/new/<int:screen>/<string:request_id>", methods=["POST"])
def requests_update(screen=1, request_id=None):
screen = int(screen)
post_data = str(request.data)
post_data = request.form
current_user = g.current_user
existing_request = Requests.get(request_id) if request_id is not None else None
jedi_flow = JEDIRequestFlow(
@@ -91,7 +91,7 @@ def requests_update(screen=1, request_id=None):
where = "/requests"
else:
where = url_for(
"requests.requests_Form_update", screen=jedi_flow.next_screen, request_id=jedi_flow.request_id
"requests.requests_form_update", screen=jedi_flow.next_screen, request_id=jedi_flow.request_id
)
return redirect(where)
else:
@@ -120,6 +120,11 @@ def update_financial_verification():
pass
@requests_bp.route("/requests/submit/<string:request_id>", methods=["POST"])
def requests_submit(request_id=None):
pass
class JEDIRequestFlow(object):
def __init__(
self,
@@ -240,7 +245,7 @@ class JEDIRequestFlow(object):
self.form_section: self.form.data
}
if self.request_id:
Requests.update(request_id, request_data)
Requests.update(self.request_id, request_data)
else:
request = Requests.create(self.current_user["id"], request_data)
self.request_id = request.id