use macro for request review fields

This commit is contained in:
dandds 2018-09-05 15:41:51 -04:00
parent 038cceb34b
commit 50c8766a7a
2 changed files with 55 additions and 195 deletions

View File

@ -50,6 +50,15 @@ def mixedContentToJson(value):
return app.jinja_env.filters["tojson"](value) return app.jinja_env.filters["tojson"](value)
def findFilter(value, filter_name, filter_args=[]):
if not filter_name:
return value
elif filter_name in app.jinja_env.filters:
return app.jinja_env.filters[filter_name](value, *filter_args)
else:
raise ValueError("filter name {} not found".format(filter_name))
def register_filters(app): def register_filters(app):
app.jinja_env.filters["iconSvg"] = iconSvg app.jinja_env.filters["iconSvg"] = iconSvg
app.jinja_env.filters["dollars"] = dollars app.jinja_env.filters["dollars"] = dollars
@ -57,3 +66,4 @@ def register_filters(app):
app.jinja_env.filters["readableInteger"] = readableInteger app.jinja_env.filters["readableInteger"] = readableInteger
app.jinja_env.filters["getOptionLabel"] = getOptionLabel app.jinja_env.filters["getOptionLabel"] = getOptionLabel
app.jinja_env.filters["mixedContentToJson"] = mixedContentToJson app.jinja_env.filters["mixedContentToJson"] = mixedContentToJson
app.jinja_env.filters["findFilter"] = findFilter

View File

@ -2,6 +2,20 @@
<span class='label label--error'>Response Required</span> <span class='label label--error'>Response Required</span>
{%- endmacro %} {%- endmacro %}
{% macro DefinitionReviewField(title, section, item_name, filter=None, filter_args=[]) -%}
<div>
<dt>{{ title }}</dt>
<dd>
{% if data[section] and data[section][item_name] %}
{{ data[section][item_name] | findFilter(filter, filter_args) }}
{% else %}
{{ RequiredLabel() }}
{% endif %}
</dd>
</div>
{% endmacro %}
<hr> <hr>
<h2> <h2>
Details of Use Details of Use
@ -14,161 +28,51 @@
</h2> </h2>
<dl> <dl>
<div>
<dt>DoD Component</dt>
<dd>
{% if data['details_of_use']['dod_component'] %}
{{ data['details_of_use']['dod_component'] | getOptionLabel(service_branches) }}
{% else %}
{{ RequiredLabel() }}
{% endif %}
</dd>
</div>
<div> {{ DefinitionReviewField("DoD Component", "details_of_use", "dod_component", filter="getOptionLabel", filter_args=[service_branches]) }}
<dt>JEDI Usage</dt>
<dd>{{ data['details_of_use']['jedi_usage'] or RequiredLabel() }}</dd>
</div>
<div> {{ DefinitionReviewField("JEDI Usage", "details_of_use", "jedi_usage") }}
<dt>Number of software systems</dt>
<dd>
{% if data['details_of_use']['num_software_systems'] %}
{{ data['details_of_use']['num_software_systems'] | readableInteger }}
{% else %}
{{ RequiredLabel() }}
{% endif %}
</dd>
</div>
<div> {{ DefinitionReviewField("Number of software systems", "details_of_use", "num_software_systems", filter="readableInteger") }}
<dt>JEDI Migration</dt>
<dd>{{ data['details_of_use']['jedi_migration'] or RequiredLabel() }}</dd> {{ DefinitionReviewField("JEDI Migration", "details_of_use", "jedi_migration") }}
</div>
{% if data['details_of_use']['jedi_migration'] == 'yes' %} {% if data['details_of_use']['jedi_migration'] == 'yes' %}
<div> {{ DefinitionReviewField("Rationalization of Software Systems", "details_of_use", "rationalization_software_systems") }}
<dt>Rationalization of Software Systems</dt>
<dd>{{ data['details_of_use']['rationalization_software_systems'] or RequiredLabel() }}</dd>
</div>
<div>
<dt>Technical Support Team</dt>
<dd>{{ data['details_of_use']['technical_support_team'] or RequiredLabel() }}</dd>
</div>
{{ DefinitionReviewField("Technical Support Team", "details_of_use", "technical_support_team") }}
{% if data['details_of_use']['technical_support_team'] == 'yes' %} {% if data['details_of_use']['technical_support_team'] == 'yes' %}
<div> {{ DefinitionReviewField("Organization Providing Assistance", "details_of_use", "organization_providing_assistance", filter="getOptionLabel", filter_args=[assistance_org_types]) }}
<dt>Organization Providing Assistance</dt>
<dd>
{% if data['details_of_use']['organization_providing_assistance'] %}
{{ data['details_of_use']['organization_providing_assistance'] | getOptionLabel(assistance_org_types) }}
{% else %}
{{ RequiredLabel() }}
{% endif %}
</dd>
</div>
{% endif %} {% endif %}
<div> {{ DefinitionReviewField("Engineering Assessment", "details_of_use", "engineering_assessment") }}
<dt>Engineering Assessment</dt>
<dd>{{ data['details_of_use']['engineering_assessment'] or RequiredLabel() }}</dd>
</div>
<div> {{ DefinitionReviewField("Data Transfers", "details_of_use", "data_transfers", filter="getOptionLabel", filter_args=[data_transfer_amounts]) }}
<dt>Data Transfers</dt>
<dd>
{% if data['details_of_use']['data_transfers'] %}
{{ data['details_of_use']['data_transfers'] | getOptionLabel(data_transfer_amounts) }}
{% else %}
{{ RequiredLabel() }}
{% endif %}
</dd>
</div>
<div> {{ DefinitionReviewField("Expected Completion Date", "details_of_use", "expected_completion_date", filter="getOptionLabel", filter_args=[completion_date_ranges]) }}
<dt>Expected Completion Date</dt>
<dd>
{% if data['details_of_use']['expected_completion_date'] %}
{{ data['details_of_use']['expected_completion_date'] | getOptionLabel(completion_date_ranges) }}
{% else %}
{{ RequiredLabel() }}
{% endif %}
</dd>
</div>
{% else %} {% else %}
<div> {{ DefinitionReviewField("Cloud Native", "details_of_use", "cloud_native") }}
<dt>Cloud Native</dt>
<dd>{{ data['details_of_use']['cloud_native'] or RequiredLabel() }}</dd>
</div>
{% endif %} {% endif %}
<div> {{ DefinitionReviewField("Estimated Monthly Spend", "details_of_use", "estimated_monthly_spend", filter="dollars") }}
<dt>Estimated Monthly Spend</dt>
<dd>
{% if data['details_of_use']['estimated_monthly_spend'] %}
{{ data['details_of_use']['estimated_monthly_spend'] | dollars }}
{% else %}
{{ RequiredLabel() }}
{% endif %}
</dd>
</div>
{% if jedi_request and jedi_request.annual_spend > annual_spend_threshold %} {% if jedi_request and jedi_request.annual_spend > annual_spend_threshold %}
<div> {{ DefinitionReviewField("Number of User Sessions", "details_of_use", "number_user_sessions", filter="readableInteger") }}
<dt>Number of User Sessions</dt>
<dd>
{% if data['details_of_use']['number_user_sessions'] %}
{{ data['details_of_use']['number_user_sessions'] | readableInteger }}
{% else %}
{{ RequiredLabel() }}
{% endif %}
</dd>
</div>
<div> {{ DefinitionReviewField("Average Daily Traffic (Number of Requests)", "details_of_use", "average_daily_traffic", filter="readableInteger") }}
<dt>Average Daily Traffic (Number of Requests)</dt>
<dd> {{ DefinitionReviewField("Average Daily Traffic (GB)", "details_of_use", "average_daily_traffic_gb", filter="readableInteger") }}
{% if data['details_of_use']['average_daily_traffic'] %}
{{ data['details_of_use']['average_daily_traffic'] | readableInteger }}
{% else %}
{{ RequiredLabel() }}
{% endif %}
</dd>
</div>
<div>
<dt>Average Daily Traffic (GB)</dt>
<dd>
{% if data['details_of_use']['average_daily_traffic_gb'] %}
{{ data['details_of_use']['average_daily_traffic_gb'] | readableInteger }} GB
{% else %}
{{ RequiredLabel() }}
{% endif %}
</dd>
</div>
{% endif %} {% endif %}
<div> {{ DefinitionReviewField("Total Spend", "details_of_use", "dollar_value", filter="dollars") }}
<dt>Total Spend</dt>
<dd>
{% if data['details_of_use']['dollar_value'] %}
{{ data['details_of_use']['dollar_value'] | dollars }}
{% else %}
{{ RequiredLabel() }}
{% endif %}
</dd>
</div>
<div> {{ DefinitionReviewField("Start Date", "details_of_use", "start_date") }}
<dt>Start Date</dt>
<dd>{{ data['details_of_use']['start_date'] or RequiredLabel() }}</dd>
</div>
</dl> </dl>
<hr> <hr>
@ -183,63 +87,21 @@
</h2> </h2>
<dl> <dl>
<div> {{ DefinitionReviewField("First Name", "information_about_you", "fname_request") }}
<dt>First Name</dt>
<dd>{{ data['information_about_you']['fname_request'] or RequiredLabel() }}</dd>
</div>
<div> {{ DefinitionReviewField("Last Name", "information_about_you", "lname_request") }}
<dt>Last Name</dt>
<dd>{{ data['information_about_you']['lname_request'] or RequiredLabel() }}</dd>
</div>
<div> {{ DefinitionReviewField("Email Address", "information_about_you", "email_request") }}
<dt>Email Address</dt>
<dd>{{ data['information_about_you']['email_request'] or RequiredLabel() }}</dd>
</div>
<div> {{ DefinitionReviewField("Phone Number", "information_about_you", "phone_number", filter="usPhone") }}
<dt>Phone Number</dt>
<dd>
{% if data['information_about_you']['phone_number'] %}
{{ data['information_about_you']['phone_number'] | usPhone }}
{% else %}
{{ RequiredLabel() }}
{% endif %}
</dd>
</div>
<div> {{ DefinitionReviewField("Service Branch or Agency", "information_about_you", "service_branch", filter="getOptionLabel", filter_args=[service_branches]) }}
<dt>Service Branch or Agency</dt>
<dd>
{% if data['information_about_you']['service_branch'] %}
{{ data['information_about_you']['service_branch'] | getOptionLabel(service_branches) }}
{% else %}
{{ RequiredLabel() }}
{% endif %}
</dd>
</div>
<div> {{ DefinitionReviewField("Citizenship", "information_about_you", "citizenship") }}
<dt>Citizenship</dt>
<dd>{{ data['information_about_you']['citizenship'] or RequiredLabel() }}</dd>
</div>
<div> {{ DefinitionReviewField("Designation of Person", "information_about_you", "designation", filter="capitalize") }}
<dt>Designation of Person</dt>
<dd>
{% if data['information_about_you']['designation'] %}
{{ data['information_about_you']['designation'] | capitalize }}
{% else %}
{{ RequiredLabel() }}
{% endif %}
</dd>
</div>
<div> {{ DefinitionReviewField("Latest Information Assurance (IA) Training completion date", "information_about_you", "date_latest_training") }}
<dt>Latest Information Assurance (IA) Training completion date</dt>
<dd>{{ data['information_about_you']['date_latest_training'] or RequiredLabel() }}</dd>
</div>
</dl> </dl>
<hr> <hr>
@ -254,25 +116,13 @@
</h2> </h2>
<dl> <dl>
<div> {{ DefinitionReviewField("POC First Name", "primary_poc", "fname_poc") }}
<dt>POC First Name</dt>
<dd>{{ data['primary_poc']['fname_poc'] or RequiredLabel() }}</dd>
</div>
<div> {{ DefinitionReviewField("POC Last Name", "primary_poc", "lname_poc") }}
<dt>POC Last Name</dt>
<dd>{{ data['primary_poc']['lname_poc'] or RequiredLabel() }}</dd>
</div>
<div> {{ DefinitionReviewField("POC Email Address", "primary_poc", "email_poc") }}
<dt>POC Email Address</dt>
<dd>{{ data['primary_poc']['email_poc'] or RequiredLabel() }}</dd>
</div>
<div> {{ DefinitionReviewField("DOD ID", "primary_poc", "dodid_poc") }}
<dt>DOD ID</dt>
<dd>{{ data['primary_poc']['dodid_poc'] or RequiredLabel() }}</dd>
</div>
</dl> </dl>