mirror of
https://github.com/almet/copanier.git
synced 2025-04-28 19:42:37 +02:00
Add Response.xlsx
This commit is contained in:
parent
be5275053b
commit
f7b90a392f
1 changed files with 9 additions and 12 deletions
|
@ -23,6 +23,12 @@ class Response(Response):
|
||||||
self.cookies.set("message", "")
|
self.cookies.set("message", "")
|
||||||
self.body = env.get_template(template_name).render(*args, **context)
|
self.body = env.get_template(template_name).render(*args, **context)
|
||||||
|
|
||||||
|
def xlsx(self, body, filename="epinamap.xlsx"):
|
||||||
|
self.body = body
|
||||||
|
mimetype = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
||||||
|
self.headers["Content-Disposition"] = f'attachment; filename="{filename}"'
|
||||||
|
self.headers["Content-Type"] = f"{mimetype}; charset=utf-8"
|
||||||
|
|
||||||
def redirect(self, location):
|
def redirect(self, location):
|
||||||
self.status = 302
|
self.status = 302
|
||||||
self.headers["Location"] = location
|
self.headers["Location"] = location
|
||||||
|
@ -184,10 +190,7 @@ async def import_products(request, response, id):
|
||||||
@app.route("/livraison/{id}/exporter/produits", methods=["GET"])
|
@app.route("/livraison/{id}/exporter/produits", methods=["GET"])
|
||||||
async def export_products(request, response, id):
|
async def export_products(request, response, id):
|
||||||
delivery = Delivery.load(id)
|
delivery = Delivery.load(id)
|
||||||
response.body = reports.products(delivery)
|
response.xlsx(reports.products(delivery))
|
||||||
mimetype = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
|
||||||
response.headers["Content-Disposition"] = f'attachment; filename="epinamap.xlsx"'
|
|
||||||
response.headers["Content-Type"] = f"{mimetype}; charset=utf-8"
|
|
||||||
|
|
||||||
|
|
||||||
@app.route("/livraison/{id}/edit", methods=["GET"])
|
@app.route("/livraison/{id}/edit", methods=["GET"])
|
||||||
|
@ -306,19 +309,13 @@ async def import_commande(request, response, id):
|
||||||
@app.route("/livraison/{id}/rapport.xlsx", methods=["GET"])
|
@app.route("/livraison/{id}/rapport.xlsx", methods=["GET"])
|
||||||
async def xls_report(request, response, id):
|
async def xls_report(request, response, id):
|
||||||
delivery = Delivery.load(id)
|
delivery = Delivery.load(id)
|
||||||
response.body = reports.summary(delivery)
|
response.xlsx(reports.summary(delivery))
|
||||||
mimetype = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
|
||||||
response.headers["Content-Disposition"] = f'attachment; filename="epinamap.xlsx"'
|
|
||||||
response.headers["Content-Type"] = f"{mimetype}; charset=utf-8"
|
|
||||||
|
|
||||||
|
|
||||||
@app.route("/livraison/{id}/rapport-complet.xlsx", methods=["GET"])
|
@app.route("/livraison/{id}/rapport-complet.xlsx", methods=["GET"])
|
||||||
async def xls_full_report(request, response, id):
|
async def xls_full_report(request, response, id):
|
||||||
delivery = Delivery.load(id)
|
delivery = Delivery.load(id)
|
||||||
response.body = reports.full(delivery)
|
response.xlsx(reports.full(delivery))
|
||||||
mimetype = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
|
||||||
response.headers["Content-Disposition"] = f'attachment; filename="epinamap.xlsx"'
|
|
||||||
response.headers["Content-Type"] = f"{mimetype}; charset=utf-8"
|
|
||||||
|
|
||||||
|
|
||||||
def configure():
|
def configure():
|
||||||
|
|
Loading…
Reference in a new issue