Route and markup for adding internal comments
This commit is contained in:
parent
0ddbeaf176
commit
acfe714a85
8
atst/forms/internal_comment.py
Normal file
8
atst/forms/internal_comment.py
Normal file
@ -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()])
|
@ -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/<string:request_id>", 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))
|
||||
|
@ -15,17 +15,15 @@
|
||||
) }}
|
||||
{% endif %}
|
||||
|
||||
<form method="POST" action="{{ url_for("requests.submit_approval", request_id=request_id) }}" autocomplete="off">
|
||||
{{ f.csrf_token }}
|
||||
<section class='panel'>
|
||||
<header class='panel__heading request-approval__heading'>
|
||||
<h1 class='h2'>Request #{{ request_id }}</h1>
|
||||
<h1 class='h2'>Request #{{ request.id }}</h1>
|
||||
<span class='label label--info'>{{ current_status }}</span>
|
||||
</header>
|
||||
|
||||
<div class='panel__content'>
|
||||
|
||||
{% with data=data, request_id=request_id %}
|
||||
{% with data=data, request_id=request.id %}
|
||||
{% include "requests/_review.html" %}
|
||||
{% endwith %}
|
||||
|
||||
@ -34,6 +32,8 @@
|
||||
</section>
|
||||
|
||||
{% if pending_review %}
|
||||
<form method="POST" action="{{ url_for("requests.submit_approval", request_id=request.id) }}" autocomplete="off">
|
||||
{{ f.csrf_token }}
|
||||
<section class='panel'>
|
||||
<header class='panel__heading'>
|
||||
<h2 class='h3'>Approval Notes</h2>
|
||||
@ -104,25 +104,6 @@
|
||||
|
||||
|
||||
|
||||
<h4 class="h3">CCPO Internal Notes</h4>
|
||||
|
||||
<p>You may add additional comments and notes for internal CCPO reference and follow-up here.</p>
|
||||
|
||||
<div class='form-row'>
|
||||
|
||||
<div class='form-col'>
|
||||
|
||||
<div class='usa-input'>
|
||||
<label for='notes'>Internal Comments <em>(optional)</em></label>
|
||||
<textarea id='notes' placeholder='Add notes or comments for internal CCPO reference.'/></textarea>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</section>
|
||||
|
||||
<section class='action-group'>
|
||||
@ -133,8 +114,24 @@
|
||||
<span>Cancel</span>
|
||||
</a>
|
||||
</section>
|
||||
</form>
|
||||
{% endif %}
|
||||
|
||||
<section class='panel'>
|
||||
<h4 class="h3">CCPO Internal Notes</h4>
|
||||
<p>You may add additional comments and notes for internal CCPO reference and follow-up here.</p>
|
||||
<div class='form-row'>
|
||||
<div class='form-col'>
|
||||
<form method="POST" action="{{ url_for('requests.create_internal_comment', request_id=request.id) }}">
|
||||
{{ internal_comment_form.csrf_token }}
|
||||
{{ TextInput(internal_comment_form.text, paragraph=True) }}
|
||||
<button type="submit">Leave comment</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class='panel'>
|
||||
<header class='panel__heading'>
|
||||
<h2 class='h3 request-approval__columns__heading'>Approval Log</h2>
|
||||
@ -182,8 +179,6 @@
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
</form>
|
||||
</article>
|
||||
|
||||
{% endblock %}
|
||||
|
Loading…
x
Reference in New Issue
Block a user