post data and submit so review
This commit is contained in:
parent
139e31b9a4
commit
979f700e36
@ -173,6 +173,14 @@ class TaskOrders(object):
|
|||||||
"{} is not an officer role on task orders".format(officer_type)
|
"{} is not an officer role on task orders".format(officer_type)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def add_dd_254(user, task_order, dd_254_data):
|
||||||
|
dd_254 = DD254(**dd_254_data)
|
||||||
|
task_order.dd_254 = dd_254
|
||||||
|
|
||||||
|
db.session.add(task_order)
|
||||||
|
db.session.commit()
|
||||||
|
|
||||||
|
|
||||||
class DD254s:
|
class DD254s:
|
||||||
# TODO: standin implementation until we have a real download,
|
# TODO: standin implementation until we have a real download,
|
||||||
|
@ -181,4 +181,37 @@ def so_review(portfolio_id, task_order_id):
|
|||||||
|
|
||||||
form = so_review_form(task_order)
|
form = so_review_form(task_order)
|
||||||
|
|
||||||
return render_template("portfolios/task_orders/so_review.html", form=form)
|
return render_template(
|
||||||
|
"portfolios/task_orders/so_review.html",
|
||||||
|
form=form,
|
||||||
|
portfolio=task_order.portfolio,
|
||||||
|
task_order=task_order,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@portfolios_bp.route(
|
||||||
|
"/portfolios/<portfolio_id>/task_order/<task_order_id>/dd254", methods=["POST"]
|
||||||
|
)
|
||||||
|
def submit_so_review(portfolio_id, task_order_id):
|
||||||
|
task_order = TaskOrders.get(g.current_user, task_order_id)
|
||||||
|
Authorization.check_is_so(g.current_user, task_order)
|
||||||
|
|
||||||
|
form = DD254Form(http_request.form)
|
||||||
|
|
||||||
|
if form.validate():
|
||||||
|
TaskOrders.add_dd_254(task_order, form.data)
|
||||||
|
# TODO: will redirect to download, sign, upload page
|
||||||
|
return redirect(
|
||||||
|
url_for(
|
||||||
|
"portfolios.view_task_order",
|
||||||
|
portfolio_id=task_order.portfolio.id,
|
||||||
|
task_order_id=task_order.id,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
return render_template(
|
||||||
|
"portfolios/task_orders/so_review.html",
|
||||||
|
form=form,
|
||||||
|
portfolio=task_order.portfolio,
|
||||||
|
task_order=task_order,
|
||||||
|
)
|
||||||
|
@ -5,6 +5,8 @@
|
|||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
|
{% include "fragments/flash.html" %}
|
||||||
|
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<div class="panel">
|
<div class="panel">
|
||||||
|
|
||||||
@ -14,16 +16,26 @@
|
|||||||
</h1>
|
</h1>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="panel__content">
|
<div class="panel__content">
|
||||||
<h3 class="subheading">{{ "task_orders.so_review.certification" | translate }}</h3>
|
<form method="POST" action='{{ url_for("portfolios.submit_so_review", portfolio_id=portfolio.id, task_order_id=task_order.id) }}'>
|
||||||
{{ TextInput(form.certifying_official) }}
|
{{ form.csrf_token }}
|
||||||
{{ TextInput(form.co_title) }}
|
<h3 class="subheading">{{ "task_orders.so_review.certification" | translate }}</h3>
|
||||||
{{ TextInput(form.co_phone, placeholder='(123) 456-7890', validation='usPhone') }}
|
{{ TextInput(form.certifying_official) }}
|
||||||
{{ TextInput(form.co_address, paragraph=True) }}
|
{{ TextInput(form.co_title) }}
|
||||||
|
{{ TextInput(form.co_phone, placeholder='(123) 456-7890', validation='usPhone') }}
|
||||||
|
{{ TextInput(form.co_address, paragraph=True) }}
|
||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
{{ MultiCheckboxInput(form.required_distribution) }}
|
{{ MultiCheckboxInput(form.required_distribution) }}
|
||||||
|
|
||||||
|
<div class="action-group">
|
||||||
|
<button class="usa-button usa-button-big usa-button-primary">
|
||||||
|
Continue
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -12,6 +12,7 @@ from tests.factories import (
|
|||||||
PortfolioRoleFactory,
|
PortfolioRoleFactory,
|
||||||
TaskOrderFactory,
|
TaskOrderFactory,
|
||||||
UserFactory,
|
UserFactory,
|
||||||
|
DD254Factory,
|
||||||
random_future_date,
|
random_future_date,
|
||||||
random_past_date,
|
random_past_date,
|
||||||
)
|
)
|
||||||
@ -353,3 +354,37 @@ def test_so_review_page(app, client, user_session):
|
|||||||
assert (
|
assert (
|
||||||
task_order.so_first_name in co_name and task_order.so_last_name in co_name
|
task_order.so_first_name in co_name and task_order.so_last_name in co_name
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def test_submit_so_review(app, client, user_session):
|
||||||
|
portfolio = PortfolioFactory.create()
|
||||||
|
so = UserFactory.create()
|
||||||
|
PortfolioRoleFactory.create(
|
||||||
|
role=Roles.get("officer"),
|
||||||
|
portfolio=portfolio,
|
||||||
|
user=so,
|
||||||
|
status=PortfolioStatus.ACTIVE,
|
||||||
|
)
|
||||||
|
task_order = TaskOrderFactory.create(portfolio=portfolio, security_officer=so)
|
||||||
|
dd_254_data = DD254Factory.dictionary()
|
||||||
|
|
||||||
|
user_session(so)
|
||||||
|
response = client.post(
|
||||||
|
url_for(
|
||||||
|
"portfolios.submit_so_review",
|
||||||
|
portfolio_id=portfolio.id,
|
||||||
|
task_order_id=task_order.id,
|
||||||
|
),
|
||||||
|
data=dd_254_data,
|
||||||
|
)
|
||||||
|
expected_redirect = url_for(
|
||||||
|
"portfolios.view_task_order",
|
||||||
|
portfolio_id=portfolio.id,
|
||||||
|
task_order_id=task_order.id,
|
||||||
|
_external=True,
|
||||||
|
)
|
||||||
|
assert response.status_code == 302
|
||||||
|
assert response.headers["Location"] == expected_redirect
|
||||||
|
|
||||||
|
assert task_order.dd_254
|
||||||
|
assert task_order.dd_254.certifying_official == dd_254_data["certifying_official"]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user