Use nested defaultdicts to provide more helpful text for unfilled fields

This commit is contained in:
richard-dds 2018-07-12 16:41:06 -04:00
parent 5b4a8fd2d3
commit fd8629db5b
2 changed files with 34 additions and 31 deletions

View File

@ -1,4 +1,5 @@
import tornado import tornado
from collections import defaultdict
from atst.handler import BaseHandler from atst.handler import BaseHandler
from atst.forms.request import RequestForm from atst.forms.request import RequestForm
@ -129,16 +130,18 @@ class JEDIRequestFlow(object):
@property @property
def current_step_data(self): def current_step_data(self):
data = {}
if self.is_post: if self.is_post:
return self.post_data data = self.post_data
if self.request: if self.request:
if self.form_section == "review_submit": if self.form_section == "review_submit":
return self.request["body"] data = self.request["body"]
else: else:
return self.request["body"].get(self.form_section, {}) data = self.request["body"].get(self.form_section, {})
else:
return {} return defaultdict(lambda: defaultdict(lambda: 'Input required'), data)
@property @property
def can_submit(self): def can_submit(self):

View File

@ -18,78 +18,78 @@
<h4>Overall Request Details</h4> <h4>Overall Request Details</h4>
<label>What is the total estimated dollar value of the cloud resources you are requesting using the JEDI CSP Calculator? </label> <label>What is the total estimated dollar value of the cloud resources you are requesting using the JEDI CSP Calculator? </label>
<b>{{ data.get('details_of_use', {}).get('dollar_value') }}</b> <b>{{ data['details_of_use']['dollar_value'] }}</b>
<label>Please estimate the number of applications that might be supported by this request</label> <label>Please estimate the number of applications that might be supported by this request</label>
<b>{{ data.get('details_of_use', {}).get('num_applications') }}</b> <b>{{ data['details_of_use']['num_applications'] }}</b>
<label>Start Date</label> <label>Start Date</label>
<b>{{ data.get('details_of_use', {}).get('date_start') }}</b> <b>{{ data['details_of_use']['date_start'] }}</b>
<label>Please briefly describe how your team is expecting to use the JEDI Cloud</label> <label>Please briefly describe how your team is expecting to use the JEDI Cloud</label>
<b>{{ data.get('details_of_use', {}).get('app_description') }}</b> <b>{{ data['details_of_use']['app_description'] }}</b>
<label>What organizations are supported by these applications?</label> <label>What organizations are supported by these applications?</label>
<b>{{ data.get('details_of_use', {}).get('supported_organizations') }}</b> <b>{{ data['details_of_use']['supported_organizations'] }}</b>
<h4>Cloud Resources</h4> <h4>Cloud Resources</h4>
<label>Total Number of vCPU cores</label> <label>Total Number of vCPU cores</label>
<b>{{ data.get('details_of_use', {}).get('total_cores') }}</b> <b>{{ data['details_of_use']['total_cores'] }}</b>
<label>Total RAM</label> <label>Total RAM</label>
<b>{{ data.get('details_of_use', {}).get('total_ram') }}</b> <b>{{ data['details_of_use']['total_ram'] }}</b>
<label>Total object storage</label> <label>Total object storage</label>
<b>{{ data.get('details_of_use', {}).get('total_object_storage') }}</b> <b>{{ data['details_of_use']['total_object_storage'] }}</b>
<label>Total server storage</label> <label>Total server storage</label>
<b>{{ data.get('details_of_use', {}).get('total_server_storage') }}</b> <b>{{ data['details_of_use']['total_server_storage'] }}</b>
<h4>Support Staff</h4> <h4>Support Staff</h4>
<label>Do you have a contractor to advise and assist you with using cloud services?</label> <label>Do you have a contractor to advise and assist you with using cloud services?</label>
<b>{{ data.get('details_of_use', {}).get('has_contractor_advisor') }}</b> <b>{{ data['details_of_use']['has_contractor_advisor'] }}</b>
<label>Are you using the JEDI Cloud to migrate existing applications?</label> <label>Are you using the JEDI Cloud to migrate existing applications?</label>
<b>{{ data.get('details_of_use', {}).get('is_migrating_application') }}</b> <b>{{ data['details_of_use']['is_migrating_application'] }}</b>
<label>Please describe the organizations that are supporting you, include both government and contractor resources</label> <label>Please describe the organizations that are supporting you, include both government and contractor resources</label>
<b>{{ data.get('details_of_use', {}).get('supporting_organization') }}</b> <b>{{ data['details_of_use']['supporting_organization'] }}</b>
<label>Do you have a migration office that you're working with to migrate to the cloud?</label> <label>Do you have a migration office that you're working with to migrate to the cloud?</label>
<b>{{ data.get('details_of_use', {}).get('has_migration_office') }}</b> <b>{{ data['details_of_use']['has_migration_office'] }}</b>
<label>Please describe the organizations that are supporting you, include both government and contractor resources.</label> <label>Please describe the organizations that are supporting you, include both government and contractor resources.</label>
<b>{{ data.get('details_of_use', {}).get('supporting_organization') }}</b> <b>{{ data['details_of_use']['supporting_organization'] }}</b>
<br><br><hr> <br><br><hr>
<h3>Information About You <a href="{{ reverse_url('request_form_update', 2, request_id) }}">Edit</a></h3> <h3>Information About You <a href="{{ reverse_url('request_form_update', 2, request_id) }}">Edit</a></h3>
<label>First Name</label> <label>First Name</label>
<b>{{ data.get('information_about_you', {}).get('fname_request') }}</b> <b>{{ data['information_about_you']['fname_request'] }}</b>
<label>Last Name</label> <label>Last Name</label>
<b>{{ data.get('information_about_you', {}).get('lname_request') }}</b> <b>{{ data['information_about_you']['lname_request'] }}</b>
<label>Email (associated with your CAC)</label> <label>Email (associated with your CAC)</label>
<b>{{ data.get('information_about_you', {}).get('email_request') }}</b> <b>{{ data['information_about_you']['email_request'] }}</b>
<label>Phone Number</label> <label>Phone Number</label>
<b>{{ data.get('information_about_you', {}).get('phone_number') }}</b> <b>{{ data['information_about_you']['phone_number'] }}</b>
<label>Service Branch or Agency</label> <label>Service Branch or Agency</label>
<b>{{ data.get('information_about_you', {}).get('service_branch') }}</b> <b>{{ data['information_about_you']['service_branch'] }}</b>
<label>Citizenship</label> <label>Citizenship</label>
<b>{{ data.get('information_about_you', {}).get('citizenship') }}</b> <b>{{ data['information_about_you']['citizenship'] }}</b>
<label>Designation of Person</label> <label>Designation of Person</label>
<b>{{ data.get('information_about_you', {}).get('designation') }}</b> <b>{{ data['information_about_you']['designation'] }}</b>
<label>Latest Information Assurance (IA) Training completion date</label> <label>Latest Information Assurance (IA) Training completion date</label>
<b>{{ data.get('information_about_you', {}).get('date_latest_training') }}</b> <b>{{ data['information_about_you']['date_latest_training'] }}</b>
<br><br><hr> <br><br><hr>
@ -99,16 +99,16 @@
<label>POC First Name</label> <label>POC First Name</label>
<b>{{ data.get('primary_poc', {}).get('fname_poc')}}</b> <b>{{ data['primary_poc']['fname_poc']}}</b>
<label>POC Last Name</label> <label>POC Last Name</label>
<b>{{ data.get('primary_poc', {}).get('lname_poc')}}</b> <b>{{ data['primary_poc']['lname_poc']}}</b>
<label>POC Email (associated with CAC)</label> <label>POC Email (associated with CAC)</label>
<b>{{ data.get('primary_poc', {}).get('email_poc')}} </b> <b>{{ data['primary_poc']['email_poc']}} </b>
<label>DOD ID</label> <label>DOD ID</label>
<b>{{ data.get('primary_poc', {}).get('dodid_poc')}}</b> <b>{{ data['primary_poc']['dodid_poc']}}</b>
<br><br> <br><br>