From efee79a566ef03afc37f7d97af75ffda47dbf4d0 Mon Sep 17 00:00:00 2001 From: dandds Date: Thu, 9 Aug 2018 09:32:17 -0400 Subject: [PATCH] update request autopopulate to rely on creator --- atst/routes/requests/jedi_request_flow.py | 8 ++++---- tests/routes/test_request_new.py | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/atst/routes/requests/jedi_request_flow.py b/atst/routes/requests/jedi_request_flow.py index 2b8bc312..02e10e2b 100644 --- a/atst/routes/requests/jedi_request_flow.py +++ b/atst/routes/requests/jedi_request_flow.py @@ -63,11 +63,11 @@ class JEDIRequestFlow(object): # maps user data to fields in OrgForm; this should be moved into the # request initialization process when we have a request schema def map_current_user(self): - if self.current_user.id == self.request.creator: + if self.request: return { - "fname_request": self.current_user.first_name, - "lname_request": self.current_user.last_name, - "email_request": self.current_user.email + "fname_request": self.request.creator.first_name, + "lname_request": self.request.creator.last_name, + "email_request": self.request.creator.email } else: return {} diff --git a/tests/routes/test_request_new.py b/tests/routes/test_request_new.py index 565f7886..06cd47da 100644 --- a/tests/routes/test_request_new.py +++ b/tests/routes/test_request_new.py @@ -71,7 +71,7 @@ def test_nonexistent_request(client, user_session): def test_creator_info_is_autopopulated(monkeypatch, client, user_session): user = UserFactory.create() user_session(user) - request = RequestFactory.create(creator=user.id, body={"information_about_you": {}}) + request = RequestFactory.create(creator=user, body={"information_about_you": {}}) response = client.get("/requests/new/2/{}".format(request.id)) body = response.data.decode() @@ -84,7 +84,7 @@ def test_non_creator_info_is_not_autopopulated(monkeypatch, client, user_session user = UserFactory.create() creator = UserFactory.create() user_session(user) - request = RequestFactory.create(creator=creator.id, body={"information_about_you": {}}) + request = RequestFactory.create(creator=creator, body={"information_about_you": {}}) response = client.get("/requests/new/2/{}".format(request.id)) body = response.data.decode()