diff --git a/atst/handlers/request_submit.py b/atst/handlers/request_submit.py index ed842449..f4d19b3d 100644 --- a/atst/handlers/request_submit.py +++ b/atst/handlers/request_submit.py @@ -14,4 +14,16 @@ class RequestsSubmit(BaseHandler): "/requests/{}/submit".format(request_id), allow_nonstandard_methods=True ) - self.redirect("/requests") + approved = yield self._check_approved(request_id) + if approved: + self.redirect("/requests?modal=True") + else: + self.redirect("/requests") + + @tornado.gen.coroutine + def _check_approved(self, request_id): + response = yield self.requests_client.get( + "/requests/{}".format(request_id) + ) + status = response.json.get("status") + return status == "approved" diff --git a/templates/requests.html.to b/templates/requests.html.to index 1814da3f..3c385aa1 100644 --- a/templates/requests.html.to +++ b/templates/requests.html.to @@ -1,5 +1,34 @@ {% extends "base.html.to" %} +{% block modal %} + {% if modalOpen() %} + {% apply modal %} +

Your request is now approved!

+ +

+ Your next step is to create a Task Order (T.O.) associated with + JEDI Cloud. Please consult a Contracting Officer (KO) or + Contracting Officer Representative (COR) to help with this step. +

+ +

+ Once the Task Order (T.O.) has been created, we will need the following + details to create your account. These details will help keep your cloud + usage in sync with your budget. +

+ + {% module Alert("You'll need these details: ", + message="

Task Order Number

Contracting Officer: Name, E-mail and Office

" + ) %} + + +
+ Close +
+ {% end %} + {% end %} +{% end %} + {% block content %} diff --git a/tests/handlers/test_request_submit.py b/tests/handlers/test_request_submit.py new file mode 100644 index 00000000..0f60c1a1 --- /dev/null +++ b/tests/handlers/test_request_submit.py @@ -0,0 +1,49 @@ +import pytest +from tests.mocks import MOCK_USER + +ERROR_CLASS = "usa-input-error-message" +APPROVED_MOCK_REQUEST = { + "status": "approved" +} + +@pytest.mark.gen_test +def test_submit_reviewed_request(monkeypatch, http_client, base_url): + monkeypatch.setattr( + "atst.handlers.request_submit.RequestsSubmit.get_current_user", lambda s: MOCK_USER + ) + monkeypatch.setattr( + "atst.handlers.request_submit.RequestsSubmit.check_xsrf_cookie", lambda s: True + ) + # this just needs to send a known invalid form value + response = yield http_client.fetch( + base_url + "/requests/submit/1", + method="POST", + headers={"Content-Type": "application/x-www-form-urlencoded"}, + body="", + raise_error=False, + follow_redirects=False + ) + assert response.headers["Location"] == "/requests" + + +@pytest.mark.gen_test +def test_submit_autoapproved_reviewed_request(monkeypatch, http_client, base_url): + monkeypatch.setattr( + "atst.handlers.request_submit.RequestsSubmit.get_current_user", lambda s: MOCK_USER + ) + monkeypatch.setattr( + "atst.handlers.request_submit.RequestsSubmit.check_xsrf_cookie", lambda s: True + ) + monkeypatch.setattr( + "tests.mocks.MOCK_REQUEST", APPROVED_MOCK_REQUEST + ) + # this just needs to send a known invalid form value + response = yield http_client.fetch( + base_url + "/requests/submit/1", + method="POST", + headers={"Content-Type": "application/x-www-form-urlencoded"}, + body="", + raise_error=False, + follow_redirects=False + ) + assert response.headers["Location"] == "/requests?modal=True"