diff --git a/atst/forms/financial.py b/atst/forms/financial.py index 42a29d39..72fad1a8 100644 --- a/atst/forms/financial.py +++ b/atst/forms/financial.py @@ -57,12 +57,7 @@ def validate_pe_id(field, existing_request): return True -class FinancialForm(ValidatedForm): - def validate(self, *args, **kwargs): - if self.funding_type.data == "OTHER": - self.funding_type_other.validators.append(Required()) - return super().validate(*args, **kwargs) - +class BaseFinancialForm(ValidatedForm): def reset(self): """ 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()] ) + +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( description="What is the source of funding?", choices=[ diff --git a/atst/routes/requests/financial_verification.py b/atst/routes/requests/financial_verification.py index 966a9680..b7fc4993 100644 --- a/atst/routes/requests/financial_verification.py +++ b/atst/routes/requests/financial_verification.py @@ -3,15 +3,25 @@ from flask import request as http_request from . import requests_bp 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/", methods=["GET"]) def financial_verification(request_id=None): request = Requests.get(request_id) - form = FinancialForm(data=request.body.get("financial_verification")) + form = financial_form(request.body.get("financial_verification")) 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): post_data = http_request.form 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(): request_data = {"financial_verification": form.data} @@ -31,11 +41,13 @@ def update_financial_verification(request_id): Requests.update(request_id, request_data) if valid: return redirect(url_for("requests.financial_verification_submitted")) + else: form.reset() return render_template( "requests/financial_verification.html", **rerender_args ) + else: form.reset() return render_template("requests/financial_verification.html", **rerender_args) diff --git a/templates/requests/financial_verification.html b/templates/requests/financial_verification.html index 71057795..2f037d31 100644 --- a/templates/requests/financial_verification.html +++ b/templates/requests/financial_verification.html @@ -9,6 +9,13 @@
+ {% 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 %} +
@@ -35,6 +42,46 @@

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.

+ {% if extended %} +
+ {{ OptionsInput(f.funding_type) }} + + + + {{ 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' + ) }} +
+ {% endif %} + {{ TextInput( f.task_order_id, placeholder="e.g.: 1234567899C0001", @@ -83,51 +130,6 @@ {{ TextInput(f.office_cor,placeholder="e.g.: WHS") }} -
- - {{ 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' - ) }} - -
- {{ OptionsInput(f.funding_type) }} - - - - {{ 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' - ) }} -
- {% endautoescape %} {% endblock form %} diff --git a/tests/forms/test_financial.py b/tests/forms/test_financial.py index 9bc82421..19bb0612 100644 --- a/tests/forms/test_financial.py +++ b/tests/forms/test_financial.py @@ -1,6 +1,6 @@ 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", [ @@ -18,7 +18,7 @@ def test_funding_type_other_not_required_if_funding_type_is_not_other(): form_data = { "funding_type": "PROC" } - form = FinancialForm(data=form_data) + form = ExtendedFinancialForm(data=form_data) form.validate() 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 = { "funding_type": "OTHER" } - form = FinancialForm(data=form_data) + form = ExtendedFinancialForm(data=form_data) form.validate() assert "funding_type_other" in form.errors