Attempt to pull workspace owner details from form
This commit is contained in:
parent
70cc82a1e7
commit
e97fbde054
@ -128,11 +128,22 @@ class JEDIRequestFlow(object):
|
||||
def map_request_data(self, section, data):
|
||||
if section == "primary_poc":
|
||||
if data.get("am_poc", False):
|
||||
try:
|
||||
request_user_info = self.existing_request.body.get("information_about_you", {})
|
||||
except AttributeError:
|
||||
request_user_info = {}
|
||||
|
||||
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,
|
||||
"fname_poc": request_user_info.get(
|
||||
"fname_request", self.current_user.first_name
|
||||
),
|
||||
"lname_poc": request_user_info.get(
|
||||
"lname_request", self.current_user.last_name
|
||||
),
|
||||
"email_poc": request_user_info.get(
|
||||
"email_request", self.current_user.email
|
||||
),
|
||||
}
|
||||
return {section: data}
|
||||
|
5
tests/assert_util.py
Normal file
5
tests/assert_util.py
Normal file
@ -0,0 +1,5 @@
|
||||
def dict_contains(superset, subset):
|
||||
"""
|
||||
Returns True if dict a is a superset of dict b.
|
||||
"""
|
||||
return all(item in superset.items() for item in subset.items())
|
@ -4,6 +4,7 @@ from atst.domain.roles import Roles
|
||||
from atst.domain.requests import Requests
|
||||
from urllib.parse import urlencode
|
||||
|
||||
from tests.assert_util import dict_contains
|
||||
|
||||
ERROR_CLASS = "alert--error"
|
||||
|
||||
@ -161,6 +162,32 @@ def test_poc_details_can_be_autopopulated_on_new_request(client, user_session):
|
||||
assert request.body["primary_poc"]["dodid_poc"] == creator.dod_id
|
||||
|
||||
|
||||
def test_poc_autofill_checks_information_about_you_form_first(client, user_session):
|
||||
creator = UserFactory.create()
|
||||
user_session(creator)
|
||||
request = RequestFactory.create(creator=creator, body={
|
||||
"information_about_you": {
|
||||
"fname_request": "Alice",
|
||||
"lname_request": "Adams",
|
||||
"email_request": "alice.adams@mail.mil"
|
||||
}
|
||||
})
|
||||
poc_input = {
|
||||
"am_poc": "yes",
|
||||
}
|
||||
client.post(
|
||||
"/requests/new/3/{}".format(request.id),
|
||||
headers={"Content-Type": "application/x-www-form-urlencoded"},
|
||||
data=urlencode(poc_input),
|
||||
)
|
||||
request = Requests.get(request.id)
|
||||
assert dict_contains(request.body["primary_poc"], {
|
||||
"fname_poc": "Alice",
|
||||
"lname_poc": "Adams",
|
||||
"email_poc": "alice.adams@mail.mil"
|
||||
})
|
||||
|
||||
|
||||
def test_can_review_data(user_session, client):
|
||||
creator = UserFactory.create()
|
||||
user_session(creator)
|
||||
|
Loading…
x
Reference in New Issue
Block a user