Merge pull request #663 from dod-ccpo/edit-ko-sections
Allow User to Edit Sections of KO Review
This commit is contained in:
commit
d95039ea83
@ -200,23 +200,41 @@ def get_started():
|
||||
@task_orders_bp.route("/task_orders/new/<int:screen>/<task_order_id>")
|
||||
@task_orders_bp.route("/portfolios/<portfolio_id>/task_orders/new/<int:screen>")
|
||||
def new(screen, task_order_id=None, portfolio_id=None):
|
||||
workflow = ShowTaskOrderWorkflow(g.current_user, screen, task_order_id)
|
||||
|
||||
if task_order_id and screen is 4:
|
||||
task_order = TaskOrders.get(g.current_user, task_order_id)
|
||||
if not TaskOrders.all_sections_complete(task_order):
|
||||
flash("task_order_draft")
|
||||
|
||||
return render_template(
|
||||
workflow.template,
|
||||
current=screen,
|
||||
task_order_id=task_order_id,
|
||||
task_order=workflow.task_order,
|
||||
portfolio_id=portfolio_id,
|
||||
screens=workflow.display_screens,
|
||||
form=workflow.form,
|
||||
complete=workflow.is_complete,
|
||||
)
|
||||
workflow = ShowTaskOrderWorkflow(g.current_user, screen, task_order_id)
|
||||
template_args = {
|
||||
"current": screen,
|
||||
"task_order_id": task_order_id,
|
||||
"portfolio_id": portfolio_id,
|
||||
"screens": workflow.display_screens,
|
||||
"form": workflow.form,
|
||||
"complete": workflow.is_complete,
|
||||
}
|
||||
|
||||
url_args = {"screen": screen}
|
||||
if task_order_id:
|
||||
url_args["task_order_id"] = task_order_id
|
||||
else:
|
||||
url_args["portfolio_id"] = portfolio_id
|
||||
|
||||
if workflow.task_order:
|
||||
template_args["task_order"] = workflow.task_order
|
||||
if http_request.args.get("ko_edit"):
|
||||
template_args["ko_edit"] = True
|
||||
template_args["next"] = url_for(
|
||||
"portfolios.ko_review",
|
||||
portfolio_id=workflow.task_order.portfolio.id,
|
||||
task_order_id=task_order_id,
|
||||
)
|
||||
url_args["next"] = template_args["next"]
|
||||
|
||||
template_args["action_url"] = url_for("task_orders.update", **url_args)
|
||||
|
||||
return render_template(workflow.template, **template_args)
|
||||
|
||||
|
||||
@task_orders_bp.route("/task_orders/new/<int:screen>", methods=["POST"])
|
||||
@ -229,15 +247,18 @@ def update(screen, task_order_id=None, portfolio_id=None):
|
||||
workflow = UpdateTaskOrderWorkflow(
|
||||
g.current_user, form_data, screen, task_order_id, portfolio_id
|
||||
)
|
||||
|
||||
if workflow.validate():
|
||||
workflow.update()
|
||||
return redirect(
|
||||
url_for(
|
||||
if http_request.args.get("next"):
|
||||
redirect_url = http_request.args.get("next")
|
||||
else:
|
||||
redirect_url = url_for(
|
||||
"task_orders.new",
|
||||
screen=screen + 1,
|
||||
task_order_id=workflow.task_order.id,
|
||||
)
|
||||
)
|
||||
return redirect(redirect_url)
|
||||
else:
|
||||
return render_template(
|
||||
workflow.template,
|
||||
|
@ -42,15 +42,23 @@
|
||||
</div>
|
||||
|
||||
<div class="panel__content">
|
||||
<div class="h2">{{ "task_orders.new.review.app_info"| translate }}</div>
|
||||
<div class="h2">
|
||||
{{ "task_orders.new.review.app_info"| translate }}
|
||||
</div>
|
||||
{% include "fragments/task_order_review/app_info.html" %}
|
||||
<hr>
|
||||
|
||||
<div class="h2">{{ "task_orders.new.review.reporting"| translate }}</div>
|
||||
<div class="h2">
|
||||
{{ "task_orders.new.review.reporting"| translate }}
|
||||
{{ EditLink(url_for("task_orders.new", screen=1, task_order_id=task_order.id, _anchor="reporting", ko_edit=True)) }}
|
||||
</div>
|
||||
{% include "fragments/task_order_review/reporting.html" %}
|
||||
<hr>
|
||||
|
||||
<div class="h2">{{ "task_orders.new.review.funding"| translate }}</div>
|
||||
<div class="h2">
|
||||
{{ "task_orders.new.review.funding"| translate }}
|
||||
{{ EditLink(url_for("task_orders.new", screen=2, task_order_id=task_order.id, _anchor="reporting", ko_edit=True)) }}
|
||||
</div>
|
||||
{% include "fragments/task_order_review/funding.html" %}
|
||||
|
||||
<div class="form__sub-fields">
|
||||
@ -59,7 +67,10 @@
|
||||
</div>
|
||||
<hr>
|
||||
|
||||
<div class="h2">{{ "task_orders.new.review.oversight"| translate }}</div>
|
||||
<div class="h2">
|
||||
{{ "task_orders.new.review.oversight"| translate }}
|
||||
{{ EditLink(url_for("task_orders.new", screen=3, task_order_id=task_order.id, _anchor="reporting", ko_edit=True)) }}
|
||||
</div>
|
||||
{% include "fragments/task_order_review/oversight.html" %}
|
||||
<hr>
|
||||
|
||||
|
@ -9,11 +9,7 @@
|
||||
{% include "fragments/flash.html" %}
|
||||
|
||||
{% block form_action %}
|
||||
{% if task_order_id %}
|
||||
<form method='POST' action="{{ url_for('task_orders.new', screen=current, task_order_id=task_order_id) }}" autocomplete="off" enctype="multipart/form-data">
|
||||
{% else %}
|
||||
<form method='POST' action="{{ url_for('task_orders.update', screen=current, portfolio_id=portfolio_id) }}" autocomplete="off" enctype="multipart/form-data">
|
||||
{% endif %}
|
||||
<form method='POST' action="{{ action_url }}" autocomplete="off" enctype="multipart/form-data">
|
||||
{% endblock %}
|
||||
|
||||
<div class="panel">
|
||||
@ -39,7 +35,7 @@
|
||||
{% block next %}
|
||||
|
||||
<div class='action-group'>
|
||||
<input type='submit' class='usa-button usa-button-primary' value='Save & Continue' />
|
||||
<input type='submit' class='usa-button usa-button-primary' value='{{ "Save" if ko_edit else "Save & Continue" }}' />
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
||||
|
@ -11,20 +11,12 @@
|
||||
|
||||
{% block form %}
|
||||
|
||||
{% macro TOEditLink(screen=1, anchor=None) %}
|
||||
{% if task_order %}
|
||||
{{ EditLink(url_for("task_orders.new", screen=screen, task_order_id=task_order.id, _anchor=anchor)) }}
|
||||
{% else %}
|
||||
{{ EditLink(url_for("task_orders.new", screen=screen, _anchor=anchor)) }}
|
||||
{% endif %}
|
||||
{% endmacro %}
|
||||
|
||||
|
||||
<h3 class="subheading">{{ "task_orders.new.review.app_info"| translate }} {{ TOEditLink(screen=1) }}</h3>
|
||||
<h3 class="subheading">{{ "task_orders.new.review.app_info"| translate }} {{ EditLink(url_for("task_orders.new", screen=1, task_order_id=task_order.id)) }}
|
||||
</h3>
|
||||
{% include "fragments/task_order_review/app_info.html" %}
|
||||
<hr>
|
||||
|
||||
<h3 class="subheading">{{ "task_orders.new.review.reporting"| translate }} {{ TOEditLink(screen=1, anchor="reporting") }}</h3>
|
||||
<h3 class="subheading">{{ "task_orders.new.review.reporting"| translate }} {{ EditLink(url_for("task_orders.new", screen=1, task_order_id=task_order.id, anchor="reporting")) }}</h3>
|
||||
|
||||
<div class="row">
|
||||
{{
|
||||
@ -92,11 +84,11 @@
|
||||
|
||||
<hr>
|
||||
|
||||
<h3 class="subheading">{{ "task_orders.new.review.funding"| translate }} {{ TOEditLink(screen=2) }}</h3>
|
||||
<h3 class="subheading">{{ "task_orders.new.review.funding"| translate }} {{ EditLink(url_for("task_orders.new", screen=2, task_order_id=task_order.id)) }}</h3>
|
||||
{% include "fragments/task_order_review/funding.html" %}
|
||||
<hr>
|
||||
|
||||
<h3 class="subheading">{{ "task_orders.new.review.oversight"| translate }} {{ TOEditLink(screen=3) }}</h3>
|
||||
<h3 class="subheading">{{ "task_orders.new.review.oversight"| translate }} {{ EditLink(url_for("task_orders.new", screen=3, task_order_id=task_order.id)) }}</h3>
|
||||
{% include "fragments/task_order_review/oversight.html" %}
|
||||
{% endblock %}
|
||||
|
||||
|
@ -237,6 +237,24 @@ def test_update_task_order_with_existing_task_order(task_order):
|
||||
assert workflow.task_order.start_date.strftime("%m/%d/%Y") == to_data["start_date"]
|
||||
|
||||
|
||||
def test_update_to_redirects_to_ko_review(client, user_session, task_order):
|
||||
ko = UserFactory.create()
|
||||
task_order.contracting_officer = ko
|
||||
user_session(ko)
|
||||
url = url_for(
|
||||
"portfolios.ko_review",
|
||||
portfolio_id=task_order.portfolio.id,
|
||||
task_order_id=task_order.id,
|
||||
)
|
||||
response = client.post(
|
||||
url_for("task_orders.new", screen=1, task_order_id=task_order.id, next=url)
|
||||
)
|
||||
body = response.data.decode()
|
||||
|
||||
assert url in body
|
||||
assert response.status_code == 302
|
||||
|
||||
|
||||
def test_other_text_not_saved_if_other_not_checked(task_order):
|
||||
to_data = {
|
||||
**TaskOrderFactory.dictionary(),
|
||||
|
Loading…
x
Reference in New Issue
Block a user