Refactor form action for new task order templates

This commit is contained in:
Montana 2019-02-21 14:36:43 -05:00
parent 12706c3d45
commit 772ca75688
2 changed files with 10 additions and 9 deletions

View File

@ -215,6 +215,12 @@ def new(screen, task_order_id=None, portfolio_id=None):
"complete": workflow.is_complete, "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: if workflow.task_order:
template_args["task_order"] = workflow.task_order template_args["task_order"] = workflow.task_order
if http_request.args.get("ko_edit"): if http_request.args.get("ko_edit"):
@ -224,6 +230,9 @@ def new(screen, task_order_id=None, portfolio_id=None):
portfolio_id=workflow.task_order.portfolio.id, portfolio_id=workflow.task_order.portfolio.id,
task_order_id=task_order_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) return render_template(workflow.template, **template_args)

View File

@ -9,15 +9,7 @@
{% include "fragments/flash.html" %} {% include "fragments/flash.html" %}
{% block form_action %} {% block form_action %}
{% if ko_edit %} <form method='POST' action="{{ action_url }}" autocomplete="off" enctype="multipart/form-data">
<form method='POST' action="{{ url_for('task_orders.update', screen=current, task_order_id=task_order_id, next=next) }}" autocomplete="off" enctype="multipart/form-data">
{% endif %}
{% 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 %}
{% endblock %} {% endblock %}
<div class="panel"> <div class="panel">