From e8aa905a9904ecb2d30c8061258e4af31e85d8c6 Mon Sep 17 00:00:00 2001 From: dandds Date: Wed, 5 Sep 2018 17:17:30 -0400 Subject: [PATCH] display financial verification review info for ccpo --- atst/filters.py | 7 ++++ atst/forms/data.py | 8 ++++ atst/forms/financial.py | 9 +---- atst/routes/requests/approval.py | 15 +++++++- atst/routes/requests/requests_form.py | 2 + templates/requests/_review.html | 55 ++++++++++++++++++++++++++- tests/routes/test_requests_index.py | 10 ++--- 7 files changed, 90 insertions(+), 16 deletions(-) diff --git a/atst/filters.py b/atst/filters.py index e889b300..6a0eed36 100644 --- a/atst/filters.py +++ b/atst/filters.py @@ -30,6 +30,8 @@ def readableInteger(value): def getOptionLabel(value, options): + if hasattr(value, "value"): + value = value.value try: return next(tup[1] for tup in options if tup[0] == value) except StopIteration: @@ -59,6 +61,10 @@ def findFilter(value, filter_name, filter_args=[]): raise ValueError("filter name {} not found".format(filter_name)) +def renderList(value): + return app.jinja_env.filters["safe"]("
".join(value)) + + def register_filters(app): app.jinja_env.filters["iconSvg"] = iconSvg app.jinja_env.filters["dollars"] = dollars @@ -67,3 +73,4 @@ def register_filters(app): app.jinja_env.filters["getOptionLabel"] = getOptionLabel app.jinja_env.filters["mixedContentToJson"] = mixedContentToJson app.jinja_env.filters["findFilter"] = findFilter + app.jinja_env.filters["renderList"] = renderList diff --git a/atst/forms/data.py b/atst/forms/data.py index 5c7f9b7a..29b38b10 100644 --- a/atst/forms/data.py +++ b/atst/forms/data.py @@ -140,3 +140,11 @@ WORKSPACE_ROLES = [ }, ), ] + +FUNDING_TYPES = [ + ("", "- Select -"), + ("RDTE", "Research, Development, Testing & Evaluation (RDT&E)"), + ("OM", "Operations & Maintenance (O&M)"), + ("PROC", "Procurement (PROC)"), + ("OTHER", "Other"), +] diff --git a/atst/forms/financial.py b/atst/forms/financial.py index 8582486b..9f4afbb3 100644 --- a/atst/forms/financial.py +++ b/atst/forms/financial.py @@ -10,6 +10,7 @@ from atst.domain.task_orders import TaskOrders from .fields import NewlineListField, SelectField from .forms import ValidatedForm +from .data import FUNDING_TYPES PE_REGEX = re.compile( @@ -161,13 +162,7 @@ class ExtendedFinancialForm(BaseFinancialForm): funding_type = SelectField( description="What is the source of funding?", - choices=[ - ("", "- Select -"), - ("RDTE", "Research, Development, Testing & Evaluation (RDT&E)"), - ("OM", "Operations & Maintenance (O&M)"), - ("PROC", "Procurement (PROC)"), - ("OTHER", "Other"), - ], + choices=FUNDING_TYPES, validators=[Required()], render_kw={"required": False}, ) diff --git a/atst/routes/requests/approval.py b/atst/routes/requests/approval.py index ca4116c7..9df64395 100644 --- a/atst/routes/requests/approval.py +++ b/atst/routes/requests/approval.py @@ -1,11 +1,22 @@ from flask import render_template, g from . import requests_bp -from atst.forms.data import SERVICE_BRANCHES from atst.domain.requests import Requests +def task_order_dictionary(task_order): + return { + c.name: getattr(task_order, c.name) + for c in task_order.__table__.columns + if c.name not in ["id", "attachment_id"] + } + + @requests_bp.route("/requests/approval/", methods=["GET"]) def approval(request_id): request = Requests.get(g.current_user, request_id) - return render_template("requests/approval.html", data=request.body, service_branches=SERVICE_BRANCHES) + data = request.body + if request.task_order: + data["task_order"] = task_order_dictionary(request.task_order) + + return render_template("requests/approval.html", data=data, financial_review=True) diff --git a/atst/routes/requests/requests_form.py b/atst/routes/requests/requests_form.py index 1a0353bc..ca941a8c 100644 --- a/atst/routes/requests/requests_form.py +++ b/atst/routes/requests/requests_form.py @@ -9,6 +9,7 @@ from atst.forms.data import ( ASSISTANCE_ORG_TYPES, DATA_TRANSFER_AMOUNTS, COMPLETION_DATE_RANGES, + FUNDING_TYPES, ) @@ -19,6 +20,7 @@ def option_data(): "assistance_org_types": ASSISTANCE_ORG_TYPES, "data_transfer_amounts": DATA_TRANSFER_AMOUNTS, "completion_date_ranges": COMPLETION_DATE_RANGES, + "funding_types": FUNDING_TYPES, } diff --git a/templates/requests/_review.html b/templates/requests/_review.html index 576f07fc..7e7fb33d 100644 --- a/templates/requests/_review.html +++ b/templates/requests/_review.html @@ -4,7 +4,7 @@ {% macro DefinitionReviewField(title, section, item_name, filter=None, filter_args=[]) -%}
-
{{ title }}
+
{{ title | safe }}
{% if data[section] and data[section][item_name] %} {{ data[section][item_name] | findFilter(filter, filter_args) }} @@ -125,4 +125,57 @@ {{ DefinitionReviewField("DOD ID", "primary_poc", "dodid_poc") }} +{% if financial_review %} +
+

+ Financial Verification +

+
+ {{ DefinitionReviewField("Task Order Number", "task_order", "number") }} + + {{ DefinitionReviewField("What is the source of funding?", "task_order", "funding_type", filter="getOptionLabel", filter_args=[funding_types]) }} + + {% if data["task_order"] and data["task_order"]["funding_type"].value == "OTHER" %} + {{ DefinitionReviewField("If other, please specify", "task_order", "funding_type_other") }} + {% endif %} + + {{ DefinitionReviewField("
CLIN 0001
-
Unclassified IaaS and PaaS Amount
", "task_order", "clin_0001", filter="dollars") }} + + {{ DefinitionReviewField("
CLIN 0003
-
Unclassified Cloud Support Package
", "task_order", "clin_0003", filter="dollars") }} + + {{ DefinitionReviewField("
CLIN 1001
-
Unclassified IaaS and PaaS Amount
OPTION PERIOD 1
", "task_order", "clin_1001", filter="dollars") }} + + {{ DefinitionReviewField("
CLIN 1003
-
Unclassified Cloud Support Package
OPTION PERIOD 1
", "task_order", "clin_1003", filter="dollars") }} + + {{ DefinitionReviewField("
CLIN 2001
-
Unclassified IaaS and PaaS Amount
OPTION PERIOD 2
", "task_order", "clin_2001", filter="dollars") }} + + {{ DefinitionReviewField("
CLIN 2003
-
Unclassified Cloud Support Package
OPTION PERIOD 2
", "task_order", "clin_2003", filter="dollars") }} + + + + {{ DefinitionReviewField("Unique Item Identifier (UII)s related to your application(s) if you already have them", "financial_verification", "uii_ids", filter="renderList") }} + + {{ DefinitionReviewField("Program Element (PE) Number related to your request", "financial_verification", "pe_id") }} + + {{ DefinitionReviewField("Program Treasury Code", "financial_verification", "treasury_code") }} + + {{ DefinitionReviewField("Program Budget Activity (BA) Code", "financial_verification", "ba_code") }} + + {{ DefinitionReviewField("Contracting Officer First Name", "financial_verification", "fname_co") }} + + {{ DefinitionReviewField("Contracting Officer Last Name", "financial_verification", "lname_co") }} + + {{ DefinitionReviewField("Contracting Officer Email", "financial_verification", "email_co") }} + + {{ DefinitionReviewField("Contracting Officer Office", "financial_verification", "office_co") }} + + {{ DefinitionReviewField("Contracting Officer Representative (COR) First Name", "financial_verification", "fname_cor") }} + + {{ DefinitionReviewField("Contracting Officer Representative (COR) Last Name", "financial_verification", "lname_cor") }} + + {{ DefinitionReviewField("Contracting Officer Representative (COR) Email", "financial_verification", "email_cor") }} + + {{ DefinitionReviewField("Contracting Officer Representative (COR) Office", "financial_verification", "office_cor") }} +
+{% endif %} diff --git a/tests/routes/test_requests_index.py b/tests/routes/test_requests_index.py index c8d6fa5d..29300b65 100644 --- a/tests/routes/test_requests_index.py +++ b/tests/routes/test_requests_index.py @@ -30,13 +30,11 @@ def test_ccpo_sees_approval_screen(): request = RequestFactory.create() Requests.submit(request) ccpo_context = RequestsIndex(ccpo).execute() - assert ( - ccpo_context["requests"][0]["edit_link"] - == url_for("requests.approval", request_id=request.id) + assert ccpo_context["requests"][0]["edit_link"] == url_for( + "requests.approval", request_id=request.id ) mo_context = RequestsIndex(request.creator).execute() - assert ( - mo_context["requests"][0]["edit_link"] - != url_for("requests.approval", request_id=request.id) + assert mo_context["requests"][0]["edit_link"] != url_for( + "requests.approval", request_id=request.id )