diff --git a/atst/domain/requests/requests.py b/atst/domain/requests/requests.py index b2f43a64..f830d604 100644 --- a/atst/domain/requests/requests.py +++ b/atst/domain/requests/requests.py @@ -135,22 +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 status_count(cls, status, creator=None): return RequestsQuery.status_count(status, creator) diff --git a/atst/filters.py b/atst/filters.py index b0ceda9c..0ee5f1cd 100644 --- a/atst/filters.py +++ b/atst/filters.py @@ -31,7 +31,7 @@ def readableInteger(value): def getOptionLabel(value, options): if hasattr(value, "value"): - value = value.value + value = value.name try: return next(tup[1] for tup in options if tup[0] == value) except StopIteration: 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 55a4c967..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() @@ -42,8 +40,7 @@ def render_approval(request, form=None): current_status=request.status.value, pending_review=pending_review, financial_review=pending_final_approval, - pdf_available=request.task_order and request.task_order.pdf, - f=form, + f=form or CCPOReviewForm(), internal_comment_form=internal_comment_form, ) diff --git a/atst/routes/requests/financial_verification.py b/atst/routes/requests/financial_verification.py index f469334a..728f7f39 100644 --- a/atst/routes/requests/financial_verification.py +++ b/atst/routes/requests/financial_verification.py @@ -13,8 +13,15 @@ def task_order_data(task_order): return data -def financial_form(data): - if http_request.args.get("extended"): +def is_extended(request): + return ( + http_request.args.get("extended") + or request.is_pending_financial_verification_changes + ) + + +def financial_form(request, data): + if is_extended(request): return ExtendedFinancialForm(data=data) else: return FinancialForm(data=data) @@ -27,12 +34,12 @@ def financial_verification(request_id=None): if request.task_order: form_data.update(task_order_data(request.task_order)) - form = financial_form(form_data) + form = financial_form(request, form_data) return render_template( "requests/financial_verification.html", f=form, request_id=request_id, - extended=http_request.args.get("extended"), + extended=is_extended(request), ) @@ -40,9 +47,9 @@ def financial_verification(request_id=None): def update_financial_verification(request_id): post_data = http_request.form existing_request = Requests.get(g.current_user, request_id) - form = financial_form(post_data) + form = financial_form(existing_request, post_data) rerender_args = dict( - request_id=request_id, f=form, extended=http_request.args.get("extended") + request_id=request_id, f=form, extended=is_extended(existing_request) ) if form.validate(): diff --git a/atst/routes/requests/index.py b/atst/routes/requests/index.py index 5f7bf1cf..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,16 +58,14 @@ 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_acceptance( - request - ) or Requests.is_pending_ccpo_approval(request): - return url_for("requests.view_pending_request", request_id=request.id) + 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( "requests.requests_form_update", screen=1, request_id=request.id diff --git a/atst/routes/requests/requests_form.py b/atst/routes/requests/requests_form.py index 0aef5fec..80f76931 100644 --- a/atst/routes/requests/requests_form.py +++ b/atst/routes/requests/requests_form.py @@ -124,7 +124,26 @@ def requests_submit(request_id=None): return redirect("/requests?modal=pendingCCPOApproval") -@requests_bp.route("/requests/pending/", methods=["GET"]) -def view_pending_request(request_id=None): +@requests_bp.route("/requests/details/", methods=["GET"]) +def view_request_details(request_id=None): request = Requests.get(g.current_user, request_id) - return render_template("requests/view_pending.html", data=request.body) + financial_review = ( + request.is_pending_ccpo_approval + or request.is_approved + or request.is_pending_financial_verification_changes + ) + + data = request.body + if financial_review and request.task_order: + data["task_order"] = request.task_order.to_dictionary() + + return render_template( + "requests/details.html", + data=data, + request_id=request.id, + status=request.status_displayname, + 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, + ) diff --git a/templates/requests/_review.html b/templates/requests/_review.html index 4caeaf53..d93a7ed2 100644 --- a/templates/requests/_review.html +++ b/templates/requests/_review.html @@ -139,13 +139,11 @@ Financial Verification - {% if pdf_available %} -
- - Download the Task Order PDF - -
- {% endif %} +
+ + Download the Task Order PDF + +
{{ DefinitionReviewField("Task Order Information Source", "task_order", "source", filter="getOptionLabel", filter_args=[task_order_sources]) }} diff --git a/templates/requests/details.html b/templates/requests/details.html new file mode 100644 index 00000000..07bd49a7 --- /dev/null +++ b/templates/requests/details.html @@ -0,0 +1,32 @@ +{% extends "base.html" %} + +{% from "components/alert.html" import Alert %} + +{% block content %} +
+ + {% if financial_verification %} + {% include 'requests/review_menu.html' %} + {% endif %} + + {% if pending_review %} + {{ Alert('Your request is being reviewed', + message="

You cannot edit your submitted request while it is under review. Your request will be reviewed within 3 business days.

", + level='warning' + ) }} + {% endif %} + +
+
+

Request Details


+

#{{ request_id }} {{ status }}

+
+ +
+ + {% include "requests/_review.html" %} + +
+
+
+{% endblock %} diff --git a/templates/requests/financial_verification.html b/templates/requests/financial_verification.html index 25837927..f3950f00 100644 --- a/templates/requests/financial_verification.html +++ b/templates/requests/financial_verification.html @@ -6,6 +6,8 @@ {% block content %} +{% include 'requests/review_menu.html' %} +
diff --git a/templates/requests/review_menu.html b/templates/requests/review_menu.html new file mode 100644 index 00000000..b8546233 --- /dev/null +++ b/templates/requests/review_menu.html @@ -0,0 +1,21 @@ +{% set pending_url=url_for('requests.view_request_details', request_id=request_id) %} +{% set financial_url=url_for('requests.financial_verification', request_id=request_id) %} +
+ +
diff --git a/templates/requests/view_pending.html b/templates/requests/view_pending.html deleted file mode 100644 index 302b439b..00000000 --- a/templates/requests/view_pending.html +++ /dev/null @@ -1,24 +0,0 @@ -{% extends "base.html" %} - -{% from "components/alert.html" import Alert %} - -{% block content %} -
- {{ Alert('Your request is being reviewed', - message="

You cannot edit your submitted request while it is under review. Your request will be reviewed within 3 business days.

", - level='warning' - ) }} - -
-
-

View Pending Request

-
- -
- - {% include "requests/_review.html" %} - -
-
-
-{% endblock %}