diff --git a/atst/domain/requests/requests.py b/atst/domain/requests/requests.py index 1289082d..f830d604 100644 --- a/atst/domain/requests/requests.py +++ b/atst/domain/requests/requests.py @@ -135,32 +135,6 @@ class Requests(object): section in existing_request_sections for section in all_request_sections ) - @classmethod - def is_pending_financial_verification(cls, request): - return request.status == RequestStatus.PENDING_FINANCIAL_VERIFICATION - - @classmethod - def is_pending_financial_verification_changes(cls, request): - return request.status == RequestStatus.CHANGES_REQUESTED_TO_FINVER - - @classmethod - def is_pending_ccpo_acceptance(cls, request): - return request.status == RequestStatus.PENDING_CCPO_ACCEPTANCE - - @classmethod - def is_pending_ccpo_approval(cls, request): - return request.status == RequestStatus.PENDING_CCPO_APPROVAL - - @classmethod - def is_pending_ccpo_action(cls, request): - return Requests.is_pending_ccpo_acceptance( - request - ) or Requests.is_pending_ccpo_approval(request) - - @classmethod - def is_approved(cls, request): - return request.status == RequestStatus.APPROVED - @classmethod def status_count(cls, status, creator=None): return RequestsQuery.status_count(status, creator) diff --git a/atst/models/request.py b/atst/models/request.py index f0df0d6d..de374907 100644 --- a/atst/models/request.py +++ b/atst/models/request.py @@ -170,3 +170,27 @@ class Request(Base): @property def internal_comments_text(self): return self.internal_comments.text if self.internal_comments else "" + + @property + def is_pending_financial_verification(self): + return self.status == RequestStatus.PENDING_FINANCIAL_VERIFICATION + + @property + def is_pending_financial_verification_changes(self): + return self.status == RequestStatus.CHANGES_REQUESTED_TO_FINVER + + @property + def is_pending_ccpo_acceptance(self): + return self.status == RequestStatus.PENDING_CCPO_ACCEPTANCE + + @property + def is_pending_ccpo_approval(self): + return self.status == RequestStatus.PENDING_CCPO_APPROVAL + + @property + def is_pending_ccpo_action(self): + return self.is_pending_ccpo_acceptance or self.is_pending_ccpo_approval + + @property + def is_approved(self): + return self.status == RequestStatus.APPROVED diff --git a/atst/routes/requests/approval.py b/atst/routes/requests/approval.py index e813f726..1843e127 100644 --- a/atst/routes/requests/approval.py +++ b/atst/routes/requests/approval.py @@ -21,10 +21,8 @@ def map_ccpo_authorizing(user): def render_approval(request, form=None): data = request.body - pending_final_approval = Requests.is_pending_ccpo_approval(request) - pending_review = ( - Requests.is_pending_ccpo_acceptance(request) or pending_final_approval - ) + pending_final_approval = request.is_pending_ccpo_approval + pending_review = request.is_pending_ccpo_acceptance or pending_final_approval if pending_final_approval and request.task_order: data["task_order"] = request.task_order.to_dictionary() diff --git a/atst/routes/requests/financial_verification.py b/atst/routes/requests/financial_verification.py index a0fba28e..728f7f39 100644 --- a/atst/routes/requests/financial_verification.py +++ b/atst/routes/requests/financial_verification.py @@ -14,9 +14,10 @@ def task_order_data(task_order): def is_extended(request): - return http_request.args.get( - "extended" - ) or Requests.is_pending_financial_verification_changes(request) + return ( + http_request.args.get("extended") + or request.is_pending_financial_verification_changes + ) def financial_form(request, data): diff --git a/atst/routes/requests/index.py b/atst/routes/requests/index.py index 360668c0..a59b1f45 100644 --- a/atst/routes/requests/index.py +++ b/atst/routes/requests/index.py @@ -44,10 +44,8 @@ class RequestsIndex(object): num_action_required = len( [r for r in mapped_requests if r.get("action_required")] ) - pending_fv = any( - Requests.is_pending_financial_verification(r) for r in requests - ) - pending_ccpo = any(Requests.is_pending_ccpo_acceptance(r) for r in requests) + pending_fv = any(r.is_pending_financial_verification for r in requests) + pending_ccpo = any(r.is_pending_ccpo_acceptance for r in requests) return { "requests": mapped_requests, @@ -60,13 +58,13 @@ class RequestsIndex(object): def _edit_link_for_request(self, viewing_role, request): if viewing_role == "ccpo": return url_for("requests.approval", request_id=request.id) - elif Requests.is_pending_financial_verification(request): + elif request.is_pending_financial_verification: return url_for("requests.financial_verification", request_id=request.id) - elif Requests.is_pending_financial_verification_changes(request): + elif request.is_pending_financial_verification_changes: return url_for( "requests.financial_verification", request_id=request.id, extended=True ) - elif Requests.is_pending_ccpo_action(request) or Requests.is_approved(request): + elif request.is_pending_ccpo_action or request.is_approved: return url_for("requests.view_request_details", request_id=request.id) else: return url_for( diff --git a/atst/routes/requests/requests_form.py b/atst/routes/requests/requests_form.py index 5eaa3f57..80f76931 100644 --- a/atst/routes/requests/requests_form.py +++ b/atst/routes/requests/requests_form.py @@ -128,9 +128,9 @@ def requests_submit(request_id=None): def view_request_details(request_id=None): request = Requests.get(g.current_user, request_id) financial_review = ( - Requests.is_pending_ccpo_approval(request) - or Requests.is_approved(request) - or Requests.is_pending_financial_verification_changes(request) + request.is_pending_ccpo_approval + or request.is_approved + or request.is_pending_financial_verification_changes ) data = request.body @@ -142,8 +142,8 @@ def view_request_details(request_id=None): data=data, request_id=request.id, status=request.status_displayname, - pending_review=Requests.is_pending_ccpo_action(request), - financial_verification=Requests.is_pending_financial_verification(request) - or Requests.is_pending_financial_verification_changes(request), + pending_review=request.is_pending_ccpo_action, + financial_verification=request.is_pending_financial_verification + or request.is_pending_financial_verification_changes, financial_review=financial_review, )