Merge pull request #323 from dod-ccpo/internal-comments
Hook up internal request comments
This commit is contained in:
@@ -14,14 +14,12 @@ from atst.domain.exceptions import NotFoundError
|
||||
from atst.forms.ccpo_review import CCPOReviewForm
|
||||
from atst.forms.internal_comment import InternalCommentForm
|
||||
|
||||
from datetime import date
|
||||
|
||||
|
||||
def map_ccpo_authorizing(user):
|
||||
return {"fname_ccpo": user.first_name, "lname_ccpo": user.last_name}
|
||||
|
||||
|
||||
def render_approval(request, form=None):
|
||||
def render_approval(request, form=None, internal_comment_form=None):
|
||||
data = request.body
|
||||
if request.has_financial_data:
|
||||
data["task_order"] = request.task_order.to_dictionary()
|
||||
@@ -30,21 +28,8 @@ def render_approval(request, form=None):
|
||||
mo_data = map_ccpo_authorizing(g.current_user)
|
||||
form = CCPOReviewForm(data=mo_data)
|
||||
|
||||
internal_comment_form = InternalCommentForm(text=request.internal_comments_text)
|
||||
|
||||
# Dummy internal comments
|
||||
comments = [
|
||||
{
|
||||
"time_created": date(2018, 9, 18),
|
||||
"full_name_commenter": "Darth Vader",
|
||||
"message": "We'll have no more of this Obi-Wan Kenobi jibberish...and don't talk to me about your mission, either. You're fortunate he doesn't blast you into a million pieces right here. ",
|
||||
},
|
||||
{
|
||||
"time_created": date(2018, 9, 20),
|
||||
"full_name_commenter": "Grand Moff Tarkin",
|
||||
"message": "We'll have no more of this Obi-Wan Kenobi jibberish...and don't talk to me about your mission, either. You're fortunate he doesn't blast you into a million pieces right here. ",
|
||||
},
|
||||
]
|
||||
if not internal_comment_form:
|
||||
internal_comment_form = InternalCommentForm()
|
||||
|
||||
return render_template(
|
||||
"requests/approval.html",
|
||||
@@ -52,9 +37,9 @@ def render_approval(request, form=None):
|
||||
reviews=list(reversed(request.reviews)),
|
||||
request=request,
|
||||
current_status=request.status.value,
|
||||
f=form or CCPOReviewForm(),
|
||||
review_form=form or CCPOReviewForm(),
|
||||
internal_comment_form=internal_comment_form,
|
||||
comments=comments,
|
||||
comments=request.internal_comments,
|
||||
)
|
||||
|
||||
|
||||
@@ -101,10 +86,12 @@ def task_order_pdf_download(request_id):
|
||||
|
||||
@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, _anchor="ccpo-notes")
|
||||
)
|
||||
form = InternalCommentForm(http_request.form)
|
||||
request = Requests.get(g.current_user, request_id)
|
||||
if form.validate():
|
||||
Requests.add_internal_comment(g.current_user, request, form.data.get("text"))
|
||||
return redirect(
|
||||
url_for("requests.approval", request_id=request_id, _anchor="ccpo-notes")
|
||||
)
|
||||
else:
|
||||
return render_approval(request, internal_comment_form=form)
|
||||
|
Reference in New Issue
Block a user