show or hide manual TO fields based on query param
This commit is contained in:
parent
a574734a8b
commit
735b9b5179
@ -57,12 +57,7 @@ def validate_pe_id(field, existing_request):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
class FinancialForm(ValidatedForm):
|
class BaseFinancialForm(ValidatedForm):
|
||||||
def validate(self, *args, **kwargs):
|
|
||||||
if self.funding_type.data == "OTHER":
|
|
||||||
self.funding_type_other.validators.append(Required())
|
|
||||||
return super().validate(*args, **kwargs)
|
|
||||||
|
|
||||||
def reset(self):
|
def reset(self):
|
||||||
"""
|
"""
|
||||||
Reset UII info so that it can be de-parsed rendered properly.
|
Reset UII info so that it can be de-parsed rendered properly.
|
||||||
@ -117,6 +112,17 @@ class FinancialForm(ValidatedForm):
|
|||||||
"Contracting Officer Representative (COR) Office", validators=[Required()]
|
"Contracting Officer Representative (COR) Office", validators=[Required()]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class FinancialForm(BaseFinancialForm):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class ExtendedFinancialForm(BaseFinancialForm):
|
||||||
|
def validate(self, *args, **kwargs):
|
||||||
|
if self.funding_type.data == "OTHER":
|
||||||
|
self.funding_type_other.validators.append(Required())
|
||||||
|
return super().validate(*args, **kwargs)
|
||||||
|
|
||||||
funding_type = SelectField(
|
funding_type = SelectField(
|
||||||
description="What is the source of funding?",
|
description="What is the source of funding?",
|
||||||
choices=[
|
choices=[
|
||||||
|
@ -3,15 +3,25 @@ from flask import request as http_request
|
|||||||
|
|
||||||
from . import requests_bp
|
from . import requests_bp
|
||||||
from atst.domain.requests import Requests
|
from atst.domain.requests import Requests
|
||||||
from atst.forms.financial import FinancialForm
|
from atst.forms.financial import FinancialForm, ExtendedFinancialForm
|
||||||
|
|
||||||
|
|
||||||
|
def financial_form(data):
|
||||||
|
if http_request.args.get("extended"):
|
||||||
|
return ExtendedFinancialForm(data=data)
|
||||||
|
else:
|
||||||
|
return FinancialForm(data=data)
|
||||||
|
|
||||||
|
|
||||||
@requests_bp.route("/requests/verify/<string:request_id>", methods=["GET"])
|
@requests_bp.route("/requests/verify/<string:request_id>", methods=["GET"])
|
||||||
def financial_verification(request_id=None):
|
def financial_verification(request_id=None):
|
||||||
request = Requests.get(request_id)
|
request = Requests.get(request_id)
|
||||||
form = FinancialForm(data=request.body.get("financial_verification"))
|
form = financial_form(request.body.get("financial_verification"))
|
||||||
return render_template(
|
return render_template(
|
||||||
"requests/financial_verification.html", f=form, request_id=request_id
|
"requests/financial_verification.html",
|
||||||
|
f=form,
|
||||||
|
request_id=request_id,
|
||||||
|
extended=http_request.args.get("extended"),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -19,9 +29,9 @@ def financial_verification(request_id=None):
|
|||||||
def update_financial_verification(request_id):
|
def update_financial_verification(request_id):
|
||||||
post_data = http_request.form
|
post_data = http_request.form
|
||||||
existing_request = Requests.get(request_id)
|
existing_request = Requests.get(request_id)
|
||||||
form = FinancialForm(post_data)
|
form = financial_form(post_data)
|
||||||
|
|
||||||
rerender_args = dict(request_id=request_id, f=form)
|
rerender_args = dict(request_id=request_id, f=form, extended=http_request.args.get("extended"))
|
||||||
|
|
||||||
if form.validate():
|
if form.validate():
|
||||||
request_data = {"financial_verification": form.data}
|
request_data = {"financial_verification": form.data}
|
||||||
@ -31,11 +41,13 @@ def update_financial_verification(request_id):
|
|||||||
Requests.update(request_id, request_data)
|
Requests.update(request_id, request_data)
|
||||||
if valid:
|
if valid:
|
||||||
return redirect(url_for("requests.financial_verification_submitted"))
|
return redirect(url_for("requests.financial_verification_submitted"))
|
||||||
|
|
||||||
else:
|
else:
|
||||||
form.reset()
|
form.reset()
|
||||||
return render_template(
|
return render_template(
|
||||||
"requests/financial_verification.html", **rerender_args
|
"requests/financial_verification.html", **rerender_args
|
||||||
)
|
)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
form.reset()
|
form.reset()
|
||||||
return render_template("requests/financial_verification.html", **rerender_args)
|
return render_template("requests/financial_verification.html", **rerender_args)
|
||||||
|
@ -9,6 +9,13 @@
|
|||||||
<financial inline-template v-bind:initial-data='{{ f.data|tojson }}'>
|
<financial inline-template v-bind:initial-data='{{ f.data|tojson }}'>
|
||||||
<div class="col">
|
<div class="col">
|
||||||
|
|
||||||
|
{% if extended %}
|
||||||
|
{{ Alert('Task Order not found in EDA',
|
||||||
|
message="Since the Task Order (TO) number was not found in our system of record, EDA, please populate the additional fields in the form below.",
|
||||||
|
level='warning'
|
||||||
|
) }}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
<div class="panel">
|
<div class="panel">
|
||||||
|
|
||||||
<div class="panel__heading">
|
<div class="panel__heading">
|
||||||
@ -35,6 +42,46 @@
|
|||||||
|
|
||||||
<p>In order to get you access to the JEDI Cloud, we will need you to enter the details below that will help us verify and account for your Task Order.</p>
|
<p>In order to get you access to the JEDI Cloud, we will need you to enter the details below that will help us verify and account for your Task Order.</p>
|
||||||
|
|
||||||
|
{% if extended %}
|
||||||
|
<fieldset class="form__sub-fields form__sub-fields--warning">
|
||||||
|
{{ OptionsInput(f.funding_type) }}
|
||||||
|
|
||||||
|
<template v-if="funding_type == 'OTHER'" v-cloak>
|
||||||
|
{{ TextInput(f.funding_type_other) }}
|
||||||
|
</template>
|
||||||
|
|
||||||
|
{{ TextInput(
|
||||||
|
f.clin_0001,placeholder="50,000",
|
||||||
|
validation='integer'
|
||||||
|
) }}
|
||||||
|
|
||||||
|
{{ TextInput(
|
||||||
|
f.clin_0003,placeholder="13,000",
|
||||||
|
validation='integer'
|
||||||
|
) }}
|
||||||
|
|
||||||
|
{{ TextInput(
|
||||||
|
f.clin_1001,placeholder="30,000",
|
||||||
|
validation='integer'
|
||||||
|
) }}
|
||||||
|
|
||||||
|
{{ TextInput(
|
||||||
|
f.clin_1003,placeholder="7,000",
|
||||||
|
validation='integer'
|
||||||
|
) }}
|
||||||
|
|
||||||
|
{{ TextInput(
|
||||||
|
f.clin_2001,placeholder="30,000",
|
||||||
|
validation='integer'
|
||||||
|
) }}
|
||||||
|
|
||||||
|
{{ TextInput(
|
||||||
|
f.clin_2003,placeholder="7,000",
|
||||||
|
validation='integer'
|
||||||
|
) }}
|
||||||
|
</fieldset>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{{ TextInput(
|
{{ TextInput(
|
||||||
f.task_order_id,
|
f.task_order_id,
|
||||||
placeholder="e.g.: 1234567899C0001",
|
placeholder="e.g.: 1234567899C0001",
|
||||||
@ -83,51 +130,6 @@
|
|||||||
|
|
||||||
{{ TextInput(f.office_cor,placeholder="e.g.: WHS") }}
|
{{ TextInput(f.office_cor,placeholder="e.g.: WHS") }}
|
||||||
|
|
||||||
<hr>
|
|
||||||
|
|
||||||
{{ Alert('Task Order not found in EDA',
|
|
||||||
message="Since the Task Order (TO) number was not found in our system of record, EDA, please populate the additional fields in the form below.",
|
|
||||||
level='warning'
|
|
||||||
) }}
|
|
||||||
|
|
||||||
<fieldset class="form__sub-fields form__sub-fields--warning">
|
|
||||||
{{ OptionsInput(f.funding_type) }}
|
|
||||||
|
|
||||||
<template v-if="funding_type == 'OTHER'" v-cloak>
|
|
||||||
{{ TextInput(f.funding_type_other) }}
|
|
||||||
</template>
|
|
||||||
|
|
||||||
{{ TextInput(
|
|
||||||
f.clin_0001,placeholder="50,000",
|
|
||||||
validation='integer'
|
|
||||||
) }}
|
|
||||||
|
|
||||||
{{ TextInput(
|
|
||||||
f.clin_0003,placeholder="13,000",
|
|
||||||
validation='integer'
|
|
||||||
) }}
|
|
||||||
|
|
||||||
{{ TextInput(
|
|
||||||
f.clin_1001,placeholder="30,000",
|
|
||||||
validation='integer'
|
|
||||||
) }}
|
|
||||||
|
|
||||||
{{ TextInput(
|
|
||||||
f.clin_1003,placeholder="7,000",
|
|
||||||
validation='integer'
|
|
||||||
) }}
|
|
||||||
|
|
||||||
{{ TextInput(
|
|
||||||
f.clin_2001,placeholder="30,000",
|
|
||||||
validation='integer'
|
|
||||||
) }}
|
|
||||||
|
|
||||||
{{ TextInput(
|
|
||||||
f.clin_2003,placeholder="7,000",
|
|
||||||
validation='integer'
|
|
||||||
) }}
|
|
||||||
</fieldset>
|
|
||||||
|
|
||||||
|
|
||||||
{% endautoescape %}
|
{% endautoescape %}
|
||||||
{% endblock form %}
|
{% endblock form %}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from atst.forms.financial import suggest_pe_id, FinancialForm
|
from atst.forms.financial import suggest_pe_id, FinancialForm, ExtendedFinancialForm
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("input_,expected", [
|
@pytest.mark.parametrize("input_,expected", [
|
||||||
@ -18,7 +18,7 @@ def test_funding_type_other_not_required_if_funding_type_is_not_other():
|
|||||||
form_data = {
|
form_data = {
|
||||||
"funding_type": "PROC"
|
"funding_type": "PROC"
|
||||||
}
|
}
|
||||||
form = FinancialForm(data=form_data)
|
form = ExtendedFinancialForm(data=form_data)
|
||||||
form.validate()
|
form.validate()
|
||||||
assert "funding_type_other" not in form.errors
|
assert "funding_type_other" not in form.errors
|
||||||
|
|
||||||
@ -27,7 +27,7 @@ def test_funding_type_other_required_if_funding_type_is_other():
|
|||||||
form_data = {
|
form_data = {
|
||||||
"funding_type": "OTHER"
|
"funding_type": "OTHER"
|
||||||
}
|
}
|
||||||
form = FinancialForm(data=form_data)
|
form = ExtendedFinancialForm(data=form_data)
|
||||||
form.validate()
|
form.validate()
|
||||||
assert "funding_type_other" in form.errors
|
assert "funding_type_other" in form.errors
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user