From 6ef1914d2df1be7ebc154aba0e4ca1960b0b7998 Mon Sep 17 00:00:00 2001 From: Andrew Croce Date: Mon, 20 Aug 2018 13:37:24 -0400 Subject: [PATCH 1/4] import SERVICE_BRANCHES data into request form templates --- atst/routes/requests/requests_form.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/atst/routes/requests/requests_form.py b/atst/routes/requests/requests_form.py index 4839b059..090f6d5d 100644 --- a/atst/routes/requests/requests_form.py +++ b/atst/routes/requests/requests_form.py @@ -6,6 +6,7 @@ from atst.routes.requests.jedi_request_flow import JEDIRequestFlow from atst.models.permissions import Permissions from atst.models.request_status_event import RequestStatus from atst.domain.exceptions import UnauthorizedError +from atst.forms.data import SERVICE_BRANCHES @requests_bp.route("/requests/new/", methods=["GET"]) @@ -20,6 +21,7 @@ def requests_form_new(screen): current=screen, next_screen=screen + 1, can_submit=jedi_flow.can_submit, + service_branches=SERVICE_BRANCHES, ) @@ -44,6 +46,7 @@ def requests_form_update(screen=1, request_id=None): request_id=request_id, jedi_request=jedi_flow.request, can_submit=jedi_flow.can_submit, + service_branches=SERVICE_BRANCHES, ) From 55bf70ddf7346ef4cc3f15d325aa1fe5309ee7c6 Mon Sep 17 00:00:00 2001 From: Andrew Croce Date: Mon, 20 Aug 2018 13:37:46 -0400 Subject: [PATCH 2/4] add filter for getting label out of options list --- atst/filters.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/atst/filters.py b/atst/filters.py index 54e74934..072a414b 100644 --- a/atst/filters.py +++ b/atst/filters.py @@ -26,9 +26,14 @@ def readableInteger(value): return "{:,}".format(numberValue) +def getOptionLabel(value, options): + return next(tup[1] for tup in options if tup[0] == value) + + 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 + app.jinja_env.filters['getOptionLabel'] = getOptionLabel From c9bc36bef37a9b06b5db8cc85d2f8100c6f71228 Mon Sep 17 00:00:00 2001 From: Andrew Croce Date: Mon, 20 Aug 2018 13:38:04 -0400 Subject: [PATCH 3/4] use getOptionLabel filter for DOD component fields --- templates/requests/screen-4.html | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/templates/requests/screen-4.html b/templates/requests/screen-4.html index 06b5cd7b..b901c47c 100644 --- a/templates/requests/screen-4.html +++ b/templates/requests/screen-4.html @@ -8,16 +8,6 @@ {% 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", @@ -59,7 +49,7 @@
DoD Component
{% if data['details_of_use']['dod_component'] %} - {{ dod_component_choices[data['details_of_use']['dod_component']] }} + {{ data['details_of_use']['dod_component'] | getOptionLabel(service_branches) }} {% else %} {{ RequiredLabel() }} {% endif %} @@ -195,7 +185,7 @@
{% endif %} - +
Total Spend
@@ -251,7 +241,13 @@
Service Branch or Agency
-
{{ data['information_about_you']['service_branch'] or RequiredLabel() }}
+
+ {% if data['information_about_you']['service_branch'] %} + {{ data['information_about_you']['service_branch'] | getOptionLabel(service_branches) }} + {% else %} + {{ RequiredLabel() }} + {% endif %} +
From b3e82b3707227c3c4b9f4f528992b2033c050255 Mon Sep 17 00:00:00 2001 From: Andrew Croce Date: Mon, 20 Aug 2018 14:07:46 -0400 Subject: [PATCH 4/4] Add lists of other option choices --- atst/forms/data.py | 29 +++++++++++++++++++++++++ atst/forms/request.py | 31 ++++----------------------- atst/routes/requests/requests_form.py | 9 ++++++-- templates/requests/screen-4.html | 13 +++-------- 4 files changed, 43 insertions(+), 39 deletions(-) diff --git a/atst/forms/data.py b/atst/forms/data.py index 8e55ff33..83f8357d 100644 --- a/atst/forms/data.py +++ b/atst/forms/data.py @@ -46,3 +46,32 @@ SERVICE_BRANCHES = [ ("US Transportation Command (USTRANSCOM)", "US Transportation Command (USTRANSCOM)"), ("Washington Headquarters Services", "Washington Headquarters Services"), ] + +ASSISTANCE_ORG_TYPES = [ + ("In-house staff", "In-house staff"), + ("Contractor", "Contractor"), + ("Other DoD Organization", "Other DoD Organization"), + ("None", "None"), +] + +DATA_TRANSFER_AMOUNTS = [ + ("", "Select an option"), + ("Less than 100GB", "Less than 100GB"), + ("100GB-500GB", "100GB-500GB"), + ("500GB-1TB", "500GB-1TB"), + ("1TB-50TB", "1TB-50TB"), + ("50TB-100TB", "50TB-100TB"), + ("100TB-500TB", "100TB-500TB"), + ("500TB-1PB", "500TB-1PB"), + ("1PB-5PB", "1PB-5PB"), + ("5PB-10PB", "5PB-10PB"), + ("Above 10PB", "Above 10PB"), +] + +COMPLETION_DATE_RANGES = [ + ("", "Select an option"), + ("Less than 1 month", "Less than 1 month"), + ("1-3 months", "1-3 months"), + ("3-6 months", "3-6 months"), + ("Above 12 months", "Above 12 months"), +] diff --git a/atst/forms/request.py b/atst/forms/request.py index a938142f..a7c556fe 100644 --- a/atst/forms/request.py +++ b/atst/forms/request.py @@ -4,7 +4,7 @@ from wtforms.validators import Optional, Required from .fields import DateField, SelectField from .forms import ValidatedForm -from .data import SERVICE_BRANCHES +from .data import SERVICE_BRANCHES, ASSISTANCE_ORG_TYPES, DATA_TRANSFER_AMOUNTS, COMPLETION_DATE_RANGES from atst.domain.requests import Requests @@ -76,12 +76,7 @@ class RequestForm(ValidatedForm): organization_providing_assistance = RadioField( # this needs to be updated to use checkboxes instead of radio description="If you are receiving migration assistance, what is the type of organization providing assistance?", - choices=[ - ("In-house staff", "In-house staff"), - ("Contractor", "Contractor"), - ("Other DoD Organization", "Other DoD Organization"), - ("None", "None"), - ], + choices=ASSISTANCE_ORG_TYPES, default="", ) @@ -93,30 +88,12 @@ class RequestForm(ValidatedForm): data_transfers = SelectField( description="How much data is being transferred to the cloud?", - choices=[ - ("", "Select an option"), - ("Less than 100GB", "Less than 100GB"), - ("100GB-500GB", "100GB-500GB"), - ("500GB-1TB", "500GB-1TB"), - ("1TB-50TB", "1TB-50TB"), - ("50TB-100TB", "50TB-100TB"), - ("100TB-500TB", "100TB-500TB"), - ("500TB-1PB", "500TB-1PB"), - ("1PB-5PB", "1PB-5PB"), - ("5PB-10PB", "5PB-10PB"), - ("Above 10PB", "Above 10PB"), - ], + choices=DATA_TRANSFER_AMOUNTS, ) expected_completion_date = SelectField( description="When do you expect to complete your migration to the JEDI Cloud?", - choices=[ - ("", "Select an option"), - ("Less than 1 month", "Less than 1 month"), - ("1-3 months", "1-3 months"), - ("3-6 months", "3-6 months"), - ("Above 12 months", "Above 12 months"), - ], + choices=COMPLETION_DATE_RANGES, ) cloud_native = RadioField( diff --git a/atst/routes/requests/requests_form.py b/atst/routes/requests/requests_form.py index 090f6d5d..0b453603 100644 --- a/atst/routes/requests/requests_form.py +++ b/atst/routes/requests/requests_form.py @@ -6,7 +6,7 @@ from atst.routes.requests.jedi_request_flow import JEDIRequestFlow from atst.models.permissions import Permissions from atst.models.request_status_event import RequestStatus from atst.domain.exceptions import UnauthorizedError -from atst.forms.data import SERVICE_BRANCHES +from atst.forms.data import SERVICE_BRANCHES, ASSISTANCE_ORG_TYPES, DATA_TRANSFER_AMOUNTS, COMPLETION_DATE_RANGES @requests_bp.route("/requests/new/", methods=["GET"]) @@ -22,9 +22,11 @@ def requests_form_new(screen): next_screen=screen + 1, can_submit=jedi_flow.can_submit, service_branches=SERVICE_BRANCHES, + assistance_org_types=ASSISTANCE_ORG_TYPES, + data_transfer_amounts=DATA_TRANSFER_AMOUNTS, + completion_date_ranges=COMPLETION_DATE_RANGES, ) - @requests_bp.route( "/requests/new/", methods=["GET"], defaults={"request_id": None} ) @@ -47,6 +49,9 @@ def requests_form_update(screen=1, request_id=None): jedi_request=jedi_flow.request, can_submit=jedi_flow.can_submit, service_branches=SERVICE_BRANCHES, + assistance_org_types=ASSISTANCE_ORG_TYPES, + data_transfer_amounts=DATA_TRANSFER_AMOUNTS, + completion_date_ranges=COMPLETION_DATE_RANGES, ) diff --git a/templates/requests/screen-4.html b/templates/requests/screen-4.html index b901c47c..eba3884a 100644 --- a/templates/requests/screen-4.html +++ b/templates/requests/screen-4.html @@ -8,13 +8,6 @@ {% from "components/text_input.html" import TextInput %} {% from "components/icon.html" import Icon %} -{% 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 %} @@ -95,7 +88,7 @@
Organization Providing Assistance
{% if data['details_of_use']['organization_providing_assistance'] %} - {{ organization_providing_assistance_choices[data['details_of_use']['organization_providing_assistance']] }} + {{ data['details_of_use']['organization_providing_assistance'] | getOptionLabel(assistance_org_types) }} {% else %} {{ RequiredLabel() }} {% endif %} @@ -112,7 +105,7 @@
Data Transfers
{% if data['details_of_use']['data_transfers'] %} - {{ data['details_of_use']['data_transfers'] | upper | replace("_"," ")}} + {{ data['details_of_use']['data_transfers'] | getOptionLabel(data_transfer_amounts) }} {% else %} {{ RequiredLabel() }} {% endif %} @@ -123,7 +116,7 @@
Expected Completion Date
{% if data['details_of_use']['expected_completion_date'] %} - {{ data['details_of_use']['expected_completion_date'] | replace("_"," ")}} + {{ data['details_of_use']['expected_completion_date'] | getOptionLabel(completion_date_ranges) }} {% else %} {{ RequiredLabel() }} {% endif %}