Move action_required_by to Request model
This commit is contained in:
parent
762a44d9ab
commit
b18b238649
@ -153,14 +153,6 @@ class Requests(object):
|
||||
request.status_events.append(status_event)
|
||||
return request
|
||||
|
||||
@classmethod
|
||||
def action_required_by(cls, request):
|
||||
return {
|
||||
RequestStatus.STARTED: "mission_owner",
|
||||
RequestStatus.PENDING_FINANCIAL_VERIFICATION: "mission_owner",
|
||||
RequestStatus.PENDING_CCPO_APPROVAL: "ccpo",
|
||||
}.get(request.status)
|
||||
|
||||
@classmethod
|
||||
def should_auto_approve(cls, request):
|
||||
try:
|
||||
|
@ -60,3 +60,11 @@ class Request(Base):
|
||||
if last_submission:
|
||||
return pendulum.instance(last_submission.time_created)
|
||||
return None
|
||||
|
||||
@property
|
||||
def action_required_by(self):
|
||||
return {
|
||||
RequestStatus.STARTED: "mission_owner",
|
||||
RequestStatus.PENDING_FINANCIAL_VERIFICATION: "mission_owner",
|
||||
RequestStatus.PENDING_CCPO_APPROVAL: "ccpo",
|
||||
}.get(self.status)
|
||||
|
@ -4,21 +4,21 @@ from atst.domain.requests import Requests, RequestStatus
|
||||
|
||||
def test_started_request_requires_mo_action():
|
||||
request = RequestFactory.create()
|
||||
assert Requests.action_required_by(request) == "mission_owner"
|
||||
assert request.action_required_by == "mission_owner"
|
||||
|
||||
|
||||
def test_pending_financial_requires_mo_action():
|
||||
request = RequestFactory.create()
|
||||
request = Requests.set_status(request, RequestStatus.PENDING_FINANCIAL_VERIFICATION)
|
||||
|
||||
assert Requests.action_required_by(request) == "mission_owner"
|
||||
assert request.action_required_by == "mission_owner"
|
||||
|
||||
|
||||
def test_pending_ccpo_approval_requires_ccpo():
|
||||
request = RequestFactory.create()
|
||||
request = Requests.set_status(request, RequestStatus.PENDING_CCPO_APPROVAL)
|
||||
|
||||
assert Requests.action_required_by(request) == "ccpo"
|
||||
assert request.action_required_by == "ccpo"
|
||||
|
||||
|
||||
def test_request_has_creator():
|
||||
|
Loading…
x
Reference in New Issue
Block a user