From 24c041811fc9548d9469e785aa0f080690af0907 Mon Sep 17 00:00:00 2001 From: dandds Date: Mon, 20 Aug 2018 09:15:16 -0400 Subject: [PATCH 1/5] wrap traffic details on financial verification page in conditional --- templates/requests/screen-4.html | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/templates/requests/screen-4.html b/templates/requests/screen-4.html index 84c0e91e..3d992f00 100644 --- a/templates/requests/screen-4.html +++ b/templates/requests/screen-4.html @@ -21,7 +21,7 @@

Before you can submit your request, please take a moment to review the information entered in the form. You may make changes by clicking the edit link on each section. When all information looks right, go ahead and submit.

- {% if f.errors or not can_submit%} + {% if f.errors or not can_submit %} {{ Alert('Please complete all sections', message="

In order to submit your JEDI Cloud request, you'll need to complete all required sections of this form without error. Missing or invalid fields are noted below.

", level='error' @@ -114,20 +114,23 @@
{{ data['details_of_use']['dollar_value'] or RequiredLabel() }}
-
-
Number of User Sessions
-
{{ data['details_of_use']['number_user_sessions'] or RequiredLabel() }}
-
+ {% set dollar_value = data['details_of_use']['dollar_value'] | int %} + {% if dollar_value > 1000000 %} +
+
Number of User Sessions
+
{{ data['details_of_use']['number_user_sessions'] or RequiredLabel() }}
+
-
-
Average Daily Traffic (Number of Requests)
-
{{ data['details_of_use']['average_daily_traffic'] or RequiredLabel() }}
-
+
+
Average Daily Traffic (Number of Requests)
+
{{ data['details_of_use']['average_daily_traffic'] or RequiredLabel() }}
+
-
-
Average Daily Traffic (GB)
-
{{ data['details_of_use']['average_daily_traffic_gb'] or RequiredLabel() }}
-
+
+
Average Daily Traffic (GB)
+
{{ data['details_of_use']['average_daily_traffic_gb'] or RequiredLabel() }}
+
+ {% endif %}
Start Date
From 293aba230b7577870b5d784156f2b1b88af2b196 Mon Sep 17 00:00:00 2001 From: dandds Date: Mon, 20 Aug 2018 09:42:31 -0400 Subject: [PATCH 2/5] fix PT #159889979, allow resubmission of previously submitted form --- atst/domain/requests.py | 9 ++++++++- tests/domain/test_requests.py | 3 +++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/atst/domain/requests.py b/atst/domain/requests.py index fa122d71..7532b4c2 100644 --- a/atst/domain/requests.py +++ b/atst/domain/requests.py @@ -137,6 +137,13 @@ class Requests(object): return dollar_value < cls.AUTO_APPROVE_THRESHOLD + _VALID_SUBMISSION_STATUSES = [ + RequestStatus.STARTED, + RequestStatus.PENDING_FINANCIAL_VERIFICATION, + RequestStatus.PENDING_CCPO_APPROVAL, + RequestStatus.CHANGES_REQUESTED, + ] + @classmethod def should_allow_submission(cls, request): all_request_sections = [ @@ -145,7 +152,7 @@ class Requests(object): "primary_poc", ] existing_request_sections = request.body.keys() - return request.status == RequestStatus.STARTED and all( + return request.status in Requests._VALID_SUBMISSION_STATUSES and all( section in existing_request_sections for section in all_request_sections ) diff --git a/tests/domain/test_requests.py b/tests/domain/test_requests.py index 332e3c6c..83975faf 100644 --- a/tests/domain/test_requests.py +++ b/tests/domain/test_requests.py @@ -54,6 +54,9 @@ def test_dont_auto_approve_if_no_dollar_value_specified(new_request): def test_should_allow_submission(new_request): assert Requests.should_allow_submission(new_request) + RequestStatusEventFactory.create(request=new_request, new_status=RequestStatus.PENDING_FINANCIAL_VERIFICATION) + assert Requests.should_allow_submission(new_request) + del new_request.body['details_of_use'] assert not Requests.should_allow_submission(new_request) From 260560699e07f178dd8bd9865947340446223cf9 Mon Sep 17 00:00:00 2001 From: dandds Date: Mon, 20 Aug 2018 10:18:47 -0400 Subject: [PATCH 3/5] limit valid request submission statuses --- atst/domain/requests.py | 2 -- tests/domain/test_requests.py | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/atst/domain/requests.py b/atst/domain/requests.py index 7532b4c2..a1102f92 100644 --- a/atst/domain/requests.py +++ b/atst/domain/requests.py @@ -139,8 +139,6 @@ class Requests(object): _VALID_SUBMISSION_STATUSES = [ RequestStatus.STARTED, - RequestStatus.PENDING_FINANCIAL_VERIFICATION, - RequestStatus.PENDING_CCPO_APPROVAL, RequestStatus.CHANGES_REQUESTED, ] diff --git a/tests/domain/test_requests.py b/tests/domain/test_requests.py index 83975faf..575697ba 100644 --- a/tests/domain/test_requests.py +++ b/tests/domain/test_requests.py @@ -54,7 +54,7 @@ def test_dont_auto_approve_if_no_dollar_value_specified(new_request): def test_should_allow_submission(new_request): assert Requests.should_allow_submission(new_request) - RequestStatusEventFactory.create(request=new_request, new_status=RequestStatus.PENDING_FINANCIAL_VERIFICATION) + RequestStatusEventFactory.create(request=new_request, new_status=RequestStatus.CHANGES_REQUESTED) assert Requests.should_allow_submission(new_request) del new_request.body['details_of_use'] From c88c763da27690ffe47824b95ee4925702503245 Mon Sep 17 00:00:00 2001 From: dandds Date: Mon, 20 Aug 2018 10:25:06 -0400 Subject: [PATCH 4/5] annual_spend property for requests model --- atst/models/request.py | 5 +++++ tests/models/test_requests.py | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/atst/models/request.py b/atst/models/request.py index bd14b5db..44474ca3 100644 --- a/atst/models/request.py +++ b/atst/models/request.py @@ -27,3 +27,8 @@ class Request(Base): @property def status_displayname(self): return self.status_events[-1].displayname + + @property + def annual_spend(self): + monthly = self.body.get("details_of_use", {}).get("estimated_monthly_spend", 0) + return monthly * 12 diff --git a/tests/models/test_requests.py b/tests/models/test_requests.py index 987723af..2572c7c3 100644 --- a/tests/models/test_requests.py +++ b/tests/models/test_requests.py @@ -68,3 +68,8 @@ def test_request_status_pending_deleted_displayname(): request = Requests.set_status(request, RequestStatus.CANCELED) assert request.status_displayname == "Canceled" + +def test_annual_spend(): + request = RequestFactory.create() + monthly = request.body.get("details_of_use").get("estimated_monthly_spend") + assert request.annual_spend == monthly * 12 From fa883c47bf2485fd0ce56c82c77f69270702bb22 Mon Sep 17 00:00:00 2001 From: dandds Date: Mon, 20 Aug 2018 10:33:17 -0400 Subject: [PATCH 5/5] use derived annual_spend property for requests --- atst/routes/requests/index.py | 2 +- templates/requests/screen-4.html | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/atst/routes/requests/index.py b/atst/routes/requests/index.py index 69da2058..3f41b7b9 100644 --- a/atst/routes/requests/index.py +++ b/atst/routes/requests/index.py @@ -10,7 +10,7 @@ def map_request(request): time_created = pendulum.instance(request.time_created) is_new = time_created.add(days=1) > pendulum.now() app_count = request.body.get("details_of_use", {}).get("num_software_systems", 0) - annual_usage = request.body.get("details_of_use", {}).get("dollar_value", 0) + annual_usage = request.annual_spend update_url = url_for( "requests.requests_form_update", screen=1, request_id=request.id ) diff --git a/templates/requests/screen-4.html b/templates/requests/screen-4.html index 3d992f00..6ae2fd4f 100644 --- a/templates/requests/screen-4.html +++ b/templates/requests/screen-4.html @@ -114,8 +114,7 @@
{{ data['details_of_use']['dollar_value'] or RequiredLabel() }}
- {% set dollar_value = data['details_of_use']['dollar_value'] | int %} - {% if dollar_value > 1000000 %} + {% if jedi_request and jedi_request.annual_spend > 1000000 %}
Number of User Sessions
{{ data['details_of_use']['number_user_sessions'] or RequiredLabel() }}