Add link to download official TO pdf

This commit is contained in:
Patrick Smith 2019-02-13 09:31:04 -05:00
parent 7faf413e1b
commit 1c21816810
2 changed files with 31 additions and 15 deletions

View File

@ -20,20 +20,29 @@ def download_summary(task_order_id):
) )
def send_file(attachment):
generator = app.csp.files.download(attachment.object_name)
return Response(
generator,
headers={
"Content-Disposition": "attachment; filename={}".format(attachment.filename)
},
)
@task_orders_bp.route("/task_orders/csp_estimate/<task_order_id>") @task_orders_bp.route("/task_orders/csp_estimate/<task_order_id>")
def download_csp_estimate(task_order_id): def download_csp_estimate(task_order_id):
task_order = TaskOrders.get(g.current_user, task_order_id) task_order = TaskOrders.get(g.current_user, task_order_id)
if task_order.csp_estimate: if task_order.csp_estimate:
estimate = task_order.csp_estimate return send_file(task_order.csp_estimate)
generator = app.csp.files.download(estimate.object_name)
return Response(
generator,
headers={
"Content-Disposition": "attachment; filename={}".format(
estimate.filename
)
},
)
else: else:
raise NotFoundError("task_order CSP estimate") raise NotFoundError("task_order CSP estimate")
@task_orders_bp.route("/task_orders/pdf/<task_order_id>")
def download_task_order_pdf(task_order_id):
task_order = TaskOrders.get(g.current_user, task_order_id)
if task_order.pdf:
return send_file(task_order.pdf)
else:
raise NotFoundError("task_order pdf")

View File

@ -171,10 +171,17 @@
format="M/D/YYYY"> format="M/D/YYYY">
</local-datetime> </local-datetime>
{%- endset %} {%- endset %}
{{ DocumentLink( {% if task_order.pdf %}
title="Task Order Draft", {{ DocumentLink(
link_url=all_sections_complete and url_for('task_orders.download_summary', task_order_id=task_order.id), title="Task Order",
description=description) }} link_url=url_for('task_orders.download_task_order_pdf', task_order_id=task_order.id),
description=description) }}
{% else %}
{{ DocumentLink(
title="Task Order Draft",
link_url=all_sections_complete and url_for('task_orders.download_summary', task_order_id=task_order.id),
description=description) }}
{% endif %}
</div> </div>
<hr /> <hr />
<div class="panel__content"> <div class="panel__content">