Merge branch 'master' into ui/review-and-submit
This commit is contained in:
commit
ef0dc75107
@ -137,6 +137,11 @@ class Requests(object):
|
|||||||
|
|
||||||
return dollar_value < cls.AUTO_APPROVE_THRESHOLD
|
return dollar_value < cls.AUTO_APPROVE_THRESHOLD
|
||||||
|
|
||||||
|
_VALID_SUBMISSION_STATUSES = [
|
||||||
|
RequestStatus.STARTED,
|
||||||
|
RequestStatus.CHANGES_REQUESTED,
|
||||||
|
]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def should_allow_submission(cls, request):
|
def should_allow_submission(cls, request):
|
||||||
all_request_sections = [
|
all_request_sections = [
|
||||||
@ -145,7 +150,7 @@ class Requests(object):
|
|||||||
"primary_poc",
|
"primary_poc",
|
||||||
]
|
]
|
||||||
existing_request_sections = request.body.keys()
|
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
|
section in existing_request_sections for section in all_request_sections
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -27,3 +27,8 @@ class Request(Base):
|
|||||||
@property
|
@property
|
||||||
def status_displayname(self):
|
def status_displayname(self):
|
||||||
return self.status_events[-1].displayname
|
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
|
||||||
|
@ -10,7 +10,7 @@ def map_request(request):
|
|||||||
time_created = pendulum.instance(request.time_created)
|
time_created = pendulum.instance(request.time_created)
|
||||||
is_new = time_created.add(days=1) > pendulum.now()
|
is_new = time_created.add(days=1) > pendulum.now()
|
||||||
app_count = request.body.get("details_of_use", {}).get("num_software_systems", 0)
|
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(
|
update_url = url_for(
|
||||||
"requests.requests_form_update", screen=1, request_id=request.id
|
"requests.requests_form_update", screen=1, request_id=request.id
|
||||||
)
|
)
|
||||||
|
@ -38,7 +38,7 @@
|
|||||||
|
|
||||||
<p>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.</p>
|
<p>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.</p>
|
||||||
|
|
||||||
{% if f.errors or not can_submit%}
|
{% if f.errors or not can_submit %}
|
||||||
{{ Alert('Please complete all sections',
|
{{ Alert('Please complete all sections',
|
||||||
message="<p>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.</p>",
|
message="<p>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.</p>",
|
||||||
level='error'
|
level='error'
|
||||||
@ -160,17 +160,7 @@
|
|||||||
</dd>
|
</dd>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% if (data['details_of_use']['estimated_monthly_spend'] and ((data['details_of_use']['estimated_monthly_spend'] * 12) > 1000000)) %}
|
{% if jedi_request and jedi_request.annual_spend > 1000000 %}
|
||||||
<div>
|
|
||||||
<dt>Total Spend</dt>
|
|
||||||
<dd>
|
|
||||||
{% if data['details_of_use']['dollar_value'] %}
|
|
||||||
{{ data['details_of_use']['dollar_value'] | dollars }}
|
|
||||||
{% else %}
|
|
||||||
{{ RequiredLabel() }}
|
|
||||||
{% endif %}
|
|
||||||
</dd>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<dt>Number of User Sessions</dt>
|
<dt>Number of User Sessions</dt>
|
||||||
@ -206,6 +196,17 @@
|
|||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<dt>Total Spend</dt>
|
||||||
|
<dd>
|
||||||
|
{% if data['details_of_use']['dollar_value'] %}
|
||||||
|
{{ data['details_of_use']['dollar_value'] | dollars }}
|
||||||
|
{% else %}
|
||||||
|
{{ RequiredLabel() }}
|
||||||
|
{% endif %}
|
||||||
|
</dd>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<dt>Start Date</dt>
|
<dt>Start Date</dt>
|
||||||
<dd>{{ data['details_of_use']['start_date'] or RequiredLabel() }}</dd>
|
<dd>{{ data['details_of_use']['start_date'] or RequiredLabel() }}</dd>
|
||||||
|
@ -54,6 +54,9 @@ def test_dont_auto_approve_if_no_dollar_value_specified(new_request):
|
|||||||
def test_should_allow_submission(new_request):
|
def test_should_allow_submission(new_request):
|
||||||
assert Requests.should_allow_submission(new_request)
|
assert Requests.should_allow_submission(new_request)
|
||||||
|
|
||||||
|
RequestStatusEventFactory.create(request=new_request, new_status=RequestStatus.CHANGES_REQUESTED)
|
||||||
|
assert Requests.should_allow_submission(new_request)
|
||||||
|
|
||||||
del new_request.body['details_of_use']
|
del new_request.body['details_of_use']
|
||||||
assert not Requests.should_allow_submission(new_request)
|
assert not Requests.should_allow_submission(new_request)
|
||||||
|
|
||||||
|
@ -68,3 +68,8 @@ def test_request_status_pending_deleted_displayname():
|
|||||||
request = Requests.set_status(request, RequestStatus.CANCELED)
|
request = Requests.set_status(request, RequestStatus.CANCELED)
|
||||||
|
|
||||||
assert request.status_displayname == "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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user