From b56bc232e606006f3c75ad1188b86a92f09d510f Mon Sep 17 00:00:00 2001 From: Andrew Croce Date: Mon, 20 Aug 2018 12:00:24 -0400 Subject: [PATCH 1/4] Add more template filters --- atst/filters.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/atst/filters.py b/atst/filters.py index 83dd98fd..0582d650 100644 --- a/atst/filters.py +++ b/atst/filters.py @@ -11,6 +11,22 @@ def dollars(value): return "${:,.0f}".format(numberValue) +def usPhone(number): + phone = re.sub(r'\D', '', number) + return '+1 ({}) {} - {}'.format(phone[0:3], phone[3:6], phone[6:]) + + +def readableInteger(value): + try: + numberValue = float(value) + except ValueError: + numberValue = 0 + return "{:,}".format(numberValue) + + def register_filters(app): app.jinja_env.filters['iconSvg'] = iconSvg app.jinja_env.filters['dollars'] = dollars + app.jinja_env.filters['usPhone'] = usPhone + app.jinja_env.filters['readableInteger'] = readableInteger + From 6b675afab92ac5874d01021433ea4ce71283187f Mon Sep 17 00:00:00 2001 From: Andrew Croce Date: Mon, 20 Aug 2018 12:01:16 -0400 Subject: [PATCH 2/4] Add some display pizzaz to the review and submit form --- templates/requests/screen-4.html | 165 +++++++++++++++++++++++-------- 1 file changed, 124 insertions(+), 41 deletions(-) diff --git a/templates/requests/screen-4.html b/templates/requests/screen-4.html index 84c0e91e..be7c7d2a 100644 --- a/templates/requests/screen-4.html +++ b/templates/requests/screen-4.html @@ -8,6 +8,23 @@ {% from "components/text_input.html" import TextInput %} {% from "components/icon.html" import Icon %} + +{% set dod_component_choices = { + "null": "Select an option", + "us_air_force": "US Air Force", + "us_army": "US Army", + "us_navy": "US Navy", + "us_marine_corps": "US Marine Corps", + "joint_chiefs_of_staff": "Joint Chiefs of Staff" +} %} + +{% set organization_providing_assistance_choices = { + "in_house_staff": "In-house staff", + "contractor": "Contractor", + "other_dod_organization": "Other DoD organization", + "none": "None" +} %} + {% block subtitle %}

Review & Submit

{% endblock %} @@ -40,7 +57,13 @@
DoD Component
-
{{ data['details_of_use']['dod_component'] or RequiredLabel() }}
+
+ {% if data['details_of_use']['dod_component'] %} + {{ dod_component_choices[data['details_of_use']['dod_component']] }} + {% else %} + {{ RequiredLabel() }} + {% endif %} +
@@ -51,7 +74,13 @@
Number of software systems
-
{{ data['details_of_use']['num_software_systems'] or RequiredLabel() }}
+
+ {% if data['details_of_use']['num_software_systems'] %} + {{ data['details_of_use']['num_software_systems'] | ReadableInteger }} + {% else %} + {{ RequiredLabel() }} + {% endif %} +
@@ -72,62 +101,110 @@ {% if data['details_of_use']['technical_support_team'] == 'yes' %} -
Organization Providing Assistance
-
{{ data['details_of_use']['organization_providing_assistance'] or RequiredLabel() }}
+
+ {% if data['details_of_use']['organization_providing_assistance'] %} + {{ organization_providing_assistance_choices[data['details_of_use']['organization_providing_assistance']] }} + {% else %} + {{ RequiredLabel() }} + {% endif %} +
- {% endif %} -
-
Engineering Assessment
-
{{ data['details_of_use']['engineering_assessment'] or RequiredLabel() }}
-
+
+
Engineering Assessment
+
{{ data['details_of_use']['engineering_assessment'] or RequiredLabel() }}
+
-
-
Data Transfers
-
{{ data['details_of_use']['data_transfers'] or RequiredLabel() }}
-
+
+
Data Transfers
+
+ {% if data['details_of_use']['data_transfers'] %} + {{ data['details_of_use']['data_transfers'] | upper | replace("_"," ")}} + {% else %} + {{ RequiredLabel() }} + {% endif %} +
+
-
-
Expected Completion Date
-
{{ data['details_of_use']['expected_completion_date'] or RequiredLabel() }}
-
+
+
Expected Completion Date
+
+ {% if data['details_of_use']['expected_completion_date'] %} + {{ data['details_of_use']['expected_completion_date'] | replace("_"," ")}} + {% else %} + {{ RequiredLabel() }} + {% endif %} +
+
- {% else %} + {% else %} -
-
Cloud Native
-
{{ data['details_of_use']['cloud_native'] or RequiredLabel() }}
-
+
+
Cloud Native
+
{{ data['details_of_use']['cloud_native'] or RequiredLabel() }}
+
- {% endif %} + {% endif %}
Estimated Monthly Spend
-
{{ data['details_of_use']['estimated_monthly_spend'] or RequiredLabel() }}
+
+ {% if data['details_of_use']['estimated_monthly_spend'] %} + {{ data['details_of_use']['estimated_monthly_spend'] | USDollars }} + {% else %} + {{ RequiredLabel() }} + {% endif %} +
-
-
Total Spend
-
{{ data['details_of_use']['dollar_value'] or RequiredLabel() }}
-
+ {% if (data['details_of_use']['estimated_monthly_spend'] and ((data['details_of_use']['estimated_monthly_spend'] * 12) > 1000000)) %} +
+
Total Spend
+
+ {% if data['details_of_use']['dollar_value'] %} + {{ data['details_of_use']['dollar_value'] | USDollars }} + {% else %} + {{ RequiredLabel() }} + {% endif %} +
+
-
-
Number of User Sessions
-
{{ data['details_of_use']['number_user_sessions'] or RequiredLabel() }}
-
+
+
Number of User Sessions
+
+ {% if data['details_of_use']['number_user_sessions'] %} + {{ data['details_of_use']['number_user_sessions'] | ReadableInteger }} + {% else %} + {{ RequiredLabel() }} + {% endif %} +
+
-
-
Average Daily Traffic (Number of Requests)
-
{{ data['details_of_use']['average_daily_traffic'] or RequiredLabel() }}
-
+
+
Average Daily Traffic (Number of Requests)
+
+ {% if data['details_of_use']['average_daily_traffic'] %} + {{ data['details_of_use']['average_daily_traffic'] | ReadableInteger }} + {% else %} + {{ RequiredLabel() }} + {% endif %} +
+
-
-
Average Daily Traffic (GB)
-
{{ data['details_of_use']['average_daily_traffic_gb'] or RequiredLabel() }}
-
+
+
Average Daily Traffic (GB)
+
+ {% if data['details_of_use']['average_daily_traffic_gb'] %} + {{ data['details_of_use']['average_daily_traffic_gb'] | ReadableInteger }} GB + {% else %} + {{ RequiredLabel() }} + {% endif %} +
+
+ {% endif %}
Start Date
@@ -162,7 +239,13 @@
Phone Number
-
{{ data['information_about_you']['phone_number'] or RequiredLabel() }}
+
+ {% if data['information_about_you']['phone_number'] %} + {{ data['information_about_you']['phone_number'] | USPhone }} + {% else %} + {{ RequiredLabel() }} + {% endif %} +
From 27fcaee0cd700288ecc807f750b18e1f45a08b6e Mon Sep 17 00:00:00 2001 From: Andrew Croce Date: Mon, 20 Aug 2018 12:12:01 -0400 Subject: [PATCH 3/4] fix ReadableInteger filter --- atst/filters.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/atst/filters.py b/atst/filters.py index 0582d650..54e74934 100644 --- a/atst/filters.py +++ b/atst/filters.py @@ -1,3 +1,5 @@ +import re + def iconSvg(name): with open('static/icons/'+name+'.svg') as contents: return contents.read() @@ -18,7 +20,7 @@ def usPhone(number): def readableInteger(value): try: - numberValue = float(value) + numberValue = int(value) except ValueError: numberValue = 0 return "{:,}".format(numberValue) From 66295a1e5dcde6b2d18103b5bdc8b6cf5429d70c Mon Sep 17 00:00:00 2001 From: Andrew Croce Date: Mon, 20 Aug 2018 12:12:11 -0400 Subject: [PATCH 4/4] use correct filter names --- templates/requests/screen-4.html | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/templates/requests/screen-4.html b/templates/requests/screen-4.html index be7c7d2a..86a133ab 100644 --- a/templates/requests/screen-4.html +++ b/templates/requests/screen-4.html @@ -76,7 +76,7 @@
Number of software systems
{% if data['details_of_use']['num_software_systems'] %} - {{ data['details_of_use']['num_software_systems'] | ReadableInteger }} + {{ data['details_of_use']['num_software_systems'] | readableInteger }} {% else %} {{ RequiredLabel() }} {% endif %} @@ -153,7 +153,7 @@
Estimated Monthly Spend
{% if data['details_of_use']['estimated_monthly_spend'] %} - {{ data['details_of_use']['estimated_monthly_spend'] | USDollars }} + {{ data['details_of_use']['estimated_monthly_spend'] | dollars }} {% else %} {{ RequiredLabel() }} {% endif %} @@ -165,7 +165,7 @@
Total Spend
{% if data['details_of_use']['dollar_value'] %} - {{ data['details_of_use']['dollar_value'] | USDollars }} + {{ data['details_of_use']['dollar_value'] | dollars }} {% else %} {{ RequiredLabel() }} {% endif %} @@ -176,7 +176,7 @@
Number of User Sessions
{% if data['details_of_use']['number_user_sessions'] %} - {{ data['details_of_use']['number_user_sessions'] | ReadableInteger }} + {{ data['details_of_use']['number_user_sessions'] | readableInteger }} {% else %} {{ RequiredLabel() }} {% endif %} @@ -187,7 +187,7 @@
Average Daily Traffic (Number of Requests)
{% if data['details_of_use']['average_daily_traffic'] %} - {{ data['details_of_use']['average_daily_traffic'] | ReadableInteger }} + {{ data['details_of_use']['average_daily_traffic'] | readableInteger }} {% else %} {{ RequiredLabel() }} {% endif %} @@ -198,7 +198,7 @@
Average Daily Traffic (GB)
{% if data['details_of_use']['average_daily_traffic_gb'] %} - {{ data['details_of_use']['average_daily_traffic_gb'] | ReadableInteger }} GB + {{ data['details_of_use']['average_daily_traffic_gb'] | readableInteger }} GB {% else %} {{ RequiredLabel() }} {% endif %} @@ -241,7 +241,7 @@
Phone Number
{% if data['information_about_you']['phone_number'] %} - {{ data['information_about_you']['phone_number'] | USPhone }} + {{ data['information_about_you']['phone_number'] | usPhone }} {% else %} {{ RequiredLabel() }} {% endif %} @@ -260,7 +260,13 @@
Designation of Person
-
{{ data['information_about_you']['designation'] or RequiredLabel() }}
+
+ {% if data['information_about_you']['designation'] %} + {{ data['information_about_you']['designation'] | capitalize }} + {% else %} + {{ RequiredLabel() }} + {% endif %} +