Add links to download CSP estimate
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
from io import BytesIO
|
||||
from flask import g, Response
|
||||
from flask import g, Response, current_app as app
|
||||
|
||||
from . import task_orders_bp
|
||||
from atst.domain.task_orders import TaskOrders
|
||||
@@ -17,3 +17,22 @@ def download_summary(task_order_id):
|
||||
headers={"Content-Disposition": "attachment; filename={}".format(filename)},
|
||||
mimetype="application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
||||
)
|
||||
|
||||
|
||||
@task_orders_bp.route("/task_orders/csp_estimate/<task_order_id>")
|
||||
def download_csp_estimate(task_order_id):
|
||||
task_order = TaskOrders.get(g.current_user, task_order_id)
|
||||
if task_order.csp_estimate:
|
||||
estimate = task_order.csp_estimate
|
||||
generator = app.csp.files.download(estimate.object_name)
|
||||
return Response(
|
||||
generator,
|
||||
headers={
|
||||
"Content-Disposition": "attachment; filename={}".format(
|
||||
estimate.filename
|
||||
)
|
||||
},
|
||||
)
|
||||
|
||||
else:
|
||||
raise NotFoundError("task_order CSP estimate")
|
||||
|
Reference in New Issue
Block a user