show next-steps modal when request is auto-approved

This commit is contained in:
dandds 2018-07-27 11:19:48 -04:00
parent 2befeea499
commit 94fb61682c
3 changed files with 91 additions and 1 deletions

View File

@ -14,4 +14,16 @@ class RequestsSubmit(BaseHandler):
"/requests/{}/submit".format(request_id),
allow_nonstandard_methods=True
)
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"

View File

@ -1,5 +1,34 @@
{% extends "base.html.to" %}
{% block modal %}
{% if modalOpen() %}
{% apply modal %}
<h1>Your request is now approved!</h1>
<p>
Your next step is to create a <b>Task Order (T.O.)</b> associated with
JEDI Cloud. Please consult a <b>Contracting Officer (KO)</b> or
<b>Contracting Officer Representative (COR)</b> to help with this step.
</p>
<p>
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.
</p>
{% module Alert("You'll need these details: ",
message="<p>Task Order Number</p><p>Contracting Officer: Name, E-mail and Office</p>"
) %}
<div class='action-group'>
<a href='/requests' class='action-group__action usa-button'>Close</a>
</div>
{% end %}
{% end %}
{% end %}
{% block content %}

View File

@ -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"