From acfe714a85f9b20f3e83357e623a8b74a6e50fb5 Mon Sep 17 00:00:00 2001 From: richard-dds Date: Tue, 11 Sep 2018 15:36:31 -0400 Subject: [PATCH] Route and markup for adding internal comments --- atst/forms/internal_comment.py | 8 ++++++ atst/routes/requests/approval.py | 16 +++++++++++- templates/requests/approval.html | 45 ++++++++++++++------------------ 3 files changed, 43 insertions(+), 26 deletions(-) create mode 100644 atst/forms/internal_comment.py diff --git a/atst/forms/internal_comment.py b/atst/forms/internal_comment.py new file mode 100644 index 00000000..a64833c8 --- /dev/null +++ b/atst/forms/internal_comment.py @@ -0,0 +1,8 @@ +from wtforms.fields import TextAreaField +from wtforms.validators import Optional + +from .forms import ValidatedForm + + +class InternalCommentForm(ValidatedForm): + text = TextAreaField(validators=[Optional()]) diff --git a/atst/routes/requests/approval.py b/atst/routes/requests/approval.py index de67fba4..2f15102c 100644 --- a/atst/routes/requests/approval.py +++ b/atst/routes/requests/approval.py @@ -12,6 +12,7 @@ from . import requests_bp from atst.domain.requests import Requests from atst.domain.exceptions import NotFoundError from atst.forms.ccpo_review import CCPOReviewForm +from atst.forms.internal_comment import InternalCommentForm def task_order_dictionary(task_order): @@ -31,16 +32,19 @@ def render_approval(request, form=None): if pending_final_approval and request.task_order: data["task_order"] = task_order_dictionary(request.task_order) + internal_comment_form = InternalCommentForm(text=request.internal_comments.text) + return render_template( "requests/approval.html", data=data, status_events=reversed(request.status_events), - request_id=request.id, + request=request, 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 or CCPOReviewForm(), + internal_comment_form=internal_comment_form ) @@ -83,3 +87,13 @@ def task_order_pdf_download(request_id): else: raise NotFoundError("task_order pdf") + + +@requests_bp.route("/requests/internal_comments/", methods=["POST"]) +def create_internal_comment(request_id): + form = InternalCommentForm(http_request.form) + if form.validate(): + request = Requests.get(g.current_user, request_id) + Requests.update_internal_comments(g.current_user, request, form.data["text"]) + + return redirect(url_for("requests.approval", request_id=request_id)) diff --git a/templates/requests/approval.html b/templates/requests/approval.html index f29814fc..a8e7f450 100644 --- a/templates/requests/approval.html +++ b/templates/requests/approval.html @@ -15,17 +15,15 @@ ) }} {% endif %} -
- {{ f.csrf_token }}
-

Request #{{ request_id }}

+

Request #{{ request.id }}

{{ current_status }}
- {% with data=data, request_id=request_id %} + {% with data=data, request_id=request.id %} {% include "requests/_review.html" %} {% endwith %} @@ -34,6 +32,8 @@
{% if pending_review %} + + {{ f.csrf_token }}

Approval Notes

@@ -104,25 +104,6 @@ -

CCPO Internal Notes

- -

You may add additional comments and notes for internal CCPO reference and follow-up here.

- -
- -
- -
- - -
- -
- -
- - -
@@ -133,8 +114,24 @@ Cancel
+
{% endif %} +
+

CCPO Internal Notes

+

You may add additional comments and notes for internal CCPO reference and follow-up here.

+
+
+
+ {{ internal_comment_form.csrf_token }} + {{ TextInput(internal_comment_form.text, paragraph=True) }} + +
+
+
+ +
+

Approval Log

@@ -182,8 +179,6 @@
- - {% endblock %}