diff --git a/atst/forms/forms.py b/atst/forms/forms.py
index 2aaa4973..ce0ff791 100644
--- a/atst/forms/forms.py
+++ b/atst/forms/forms.py
@@ -6,3 +6,9 @@ class ValidatedForm(FlaskForm):
"""Performs any applicable extra validation. Must
return True if the form is valid or False otherwise."""
return True
+
+ @property
+ def data(self):
+ _data = super().data
+ _data.pop("csrf_token", None)
+ return _data
diff --git a/atst/forms/poc.py b/atst/forms/poc.py
index 3dcdc223..827bf1ae 100644
--- a/atst/forms/poc.py
+++ b/atst/forms/poc.py
@@ -1,11 +1,30 @@
-from wtforms.fields import StringField
+from wtforms.fields import StringField, BooleanField
from wtforms.fields.html5 import EmailField
-from wtforms.validators import Required, Email, Length
+from wtforms.validators import Required, Email, Length, Optional
from .forms import ValidatedForm
from .validators import IsNumber
class POCForm(ValidatedForm):
+
+ def validate(self, *args, **kwargs):
+ if self.am_poc.data:
+ # Prepend Optional validators so that the validation chain
+ # halts if no data exists.
+ self.fname_poc.validators.insert(0, Optional())
+ self.lname_poc.validators.insert(0, Optional())
+ self.email_poc.validators.insert(0, Optional())
+ self.dodid_poc.validators.insert(0, Optional())
+
+ return super().validate(*args, **kwargs)
+
+
+ am_poc = BooleanField(
+ "I am the Workspace Owner.",
+ default=False,
+ false_values=(False, "false", "False", "no", "")
+ )
+
fname_poc = StringField("First Name", validators=[Required()])
lname_poc = StringField("Last Name", validators=[Required()])
diff --git a/atst/routes/requests/jedi_request_flow.py b/atst/routes/requests/jedi_request_flow.py
index 7c96d7d5..0b56743b 100644
--- a/atst/routes/requests/jedi_request_flow.py
+++ b/atst/routes/requests/jedi_request_flow.py
@@ -65,7 +65,7 @@ class JEDIRequestFlow(object):
return {
"fname_request": user.first_name,
"lname_request": user.last_name,
- "email_request": user.email
+ "email_request": user.email,
}
@property
@@ -80,7 +80,7 @@ class JEDIRequestFlow(object):
data = self.request.body
elif self.form_section == "information_about_you":
form_data = self.request.body.get(self.form_section, {})
- data = { **self.map_user_data(self.request.creator), **form_data }
+ data = {**self.map_user_data(self.request.creator), **form_data}
else:
data = self.request.body.get(self.form_section, {})
elif self.form_section == "information_about_you":
@@ -103,40 +103,36 @@ class JEDIRequestFlow(object):
"title": "Details of Use",
"section": "details_of_use",
"form": RequestForm,
- "subitems": [
- {
- "title": "Overall request details",
- "id": "overall-request-details",
- },
- {"title": "Cloud Resources", "id": "cloud-resources"},
- {"title": "Support Staff", "id": "support-staff"},
- ],
- "show": True,
},
{
"title": "Information About You",
"section": "information_about_you",
"form": OrgForm,
- "show": True,
- },
- {
- "title": "Workspace Owner",
- "section": "primary_poc",
- "form": POCForm,
- "show": True,
},
+ {"title": "Workspace Owner", "section": "primary_poc", "form": POCForm},
{
"title": "Review & Submit",
"section": "review_submit",
"form": ReviewForm,
- "show": True,
},
]
def create_or_update_request(self):
- request_data = {self.form_section: self.form.data}
+ request_data = self.map_request_data(self.form_section, self.form.data)
if self.request_id:
Requests.update(self.request_id, request_data)
else:
request = Requests.create(self.current_user, request_data)
self.request_id = request.id
+
+ def map_request_data(self, section, data):
+ if section == "primary_poc":
+ if data.get("am_poc", False):
+ data = {
+ **data,
+ "dodid_poc": self.current_user.dod_id,
+ "fname_poc": self.current_user.first_name,
+ "lname_poc": self.current_user.last_name,
+ "email_poc": self.current_user.email,
+ }
+ return {section: data}
diff --git a/atst/routes/requests/requests_form.py b/atst/routes/requests/requests_form.py
index c027890c..4839b059 100644
--- a/atst/routes/requests/requests_form.py
+++ b/atst/routes/requests/requests_form.py
@@ -64,35 +64,30 @@ def requests_update(screen=1, request_id=None):
existing_request=existing_request,
)
- rerender_args = dict(
- f=jedi_flow.form,
- data=post_data,
- screens=jedi_flow.screens,
- current=screen,
- next_screen=jedi_flow.next_screen,
- request_id=jedi_flow.request_id,
- )
+ has_next_screen = jedi_flow.next_screen <= len(jedi_flow.screens)
+ valid = jedi_flow.validate() and jedi_flow.validate_warnings()
- if jedi_flow.validate():
+ if valid:
jedi_flow.create_or_update_request()
- valid = jedi_flow.validate_warnings()
- if valid:
- if jedi_flow.next_screen > len(jedi_flow.screens):
- where = "/requests"
- else:
- where = url_for(
- "requests.requests_form_update",
- screen=jedi_flow.next_screen,
- request_id=jedi_flow.request_id,
- )
- return redirect(where)
- else:
- return render_template(
- "requests/screen-%d.html" % int(screen), **rerender_args
+ if has_next_screen:
+ where = url_for(
+ "requests.requests_form_update",
+ screen=jedi_flow.next_screen,
+ request_id=jedi_flow.request_id,
)
-
+ else:
+ where = "/requests"
+ return redirect(where)
else:
+ rerender_args = dict(
+ f=jedi_flow.form,
+ data=post_data,
+ screens=jedi_flow.screens,
+ current=screen,
+ next_screen=jedi_flow.next_screen,
+ request_id=jedi_flow.request_id,
+ )
return render_template("requests/screen-%d.html" % int(screen), **rerender_args)
diff --git a/js/components/checkbox_input.js b/js/components/checkbox_input.js
new file mode 100644
index 00000000..6ed5e821
--- /dev/null
+++ b/js/components/checkbox_input.js
@@ -0,0 +1,16 @@
+export default {
+ name: 'checkboxinput',
+
+ props: {
+ name: String,
+ },
+
+ methods: {
+ onInput: function (e) {
+ this.$root.$emit('field-change', {
+ value: e.target.checked,
+ name: this.name
+ })
+ }
+ }
+}
diff --git a/js/components/forms/poc.js b/js/components/forms/poc.js
new file mode 100644
index 00000000..255c1b04
--- /dev/null
+++ b/js/components/forms/poc.js
@@ -0,0 +1,43 @@
+import optionsinput from '../options_input'
+import textinput from '../text_input'
+import checkboxinput from '../checkbox_input'
+
+export default {
+ name: 'poc',
+
+ components: {
+ optionsinput,
+ textinput,
+ checkboxinput,
+ },
+
+ props: {
+ initialData: {
+ type: Object,
+ default: () => ({})
+ }
+ },
+
+ data: function () {
+ const {
+ am_poc = false
+ } = this.initialData
+
+ return {
+ am_poc
+ }
+ },
+
+ mounted: function () {
+ this.$root.$on('field-change', this.handleFieldChange)
+ },
+
+ methods: {
+ handleFieldChange: function (event) {
+ const { value, name } = event
+ if (typeof this[name] !== undefined) {
+ this[name] = value
+ }
+ },
+ }
+}
diff --git a/js/index.js b/js/index.js
index 5cf47a60..afe6961d 100644
--- a/js/index.js
+++ b/js/index.js
@@ -4,7 +4,9 @@ import VTooltip from 'v-tooltip'
import optionsinput from './components/options_input'
import textinput from './components/text_input'
+import checkboxinput from './components/checkbox_input'
import DetailsOfUse from './components/forms/details_of_use'
+import poc from './components/forms/poc'
Vue.use(VTooltip)
@@ -14,7 +16,9 @@ const app = new Vue({
components: {
optionsinput,
textinput,
+ checkboxinput,
DetailsOfUse,
+ poc,
},
methods: {
closeModal: function(name) {
diff --git a/templates/components/checkbox_input.html b/templates/components/checkbox_input.html
new file mode 100644
index 00000000..92538843
--- /dev/null
+++ b/templates/components/checkbox_input.html
@@ -0,0 +1,18 @@
+
+{% macro CheckboxInput(field, inline=False) -%}
+
The Workspace Owner is the primary point of contact and technical administrator of the JEDI Workspace and will have the following responsibilities:
-This person must be a DoD employee (not a contractor).
-The Workspace Owner may be you. You will be able to add other administrators later. This person will be invited via email once your request is approved.
+The Workspace Owner is the primary point of contact and technical administrator of the JEDI Workspace and will have the + following responsibilities:
+This person must be a DoD employee (not a contractor).
+The Workspace Owner may be you. You will be able to add other administrators later. This person will be invited via email + once your request is approved.
+ {{ CheckboxInput(f.am_poc) }} + + + {{ TextInput(f.fname_poc,placeholder='First Name') }} + {{ TextInput(f.lname_poc,placeholder='Last Name') }} + {{ TextInput(f.email_poc,placeholder='jane@mail.mil', validation='email') }} + {{ TextInput(f.dodid_poc,placeholder='10-digit number on the back of the CAC', validation='dodId') }} + + +