From 698d2ef87fa8f068ee8fd34a74b5e2c752f5e72b Mon Sep 17 00:00:00 2001 From: Alexis M Date: Wed, 2 Oct 2019 20:22:39 +0200 Subject: [PATCH] Add a summary link to the email sent to referents. --- copanier/__init__.py | 14 +++++++++++++- copanier/static/app.css | 4 ++++ copanier/templates/prepare_referent_email.html | 4 +++- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/copanier/__init__.py b/copanier/__init__.py index 9401b05..10a092f 100644 --- a/copanier/__init__.py +++ b/copanier/__init__.py @@ -451,7 +451,19 @@ async def send_referent_emails(request, response, id): }) -@app.route("/livraison/{id}/{producer}/bon-de-commande", methods=["GET"]) +@app.route("/livraison/{id}/bon-de-commande-referent⋅e", methods=['GET']) +async def download_referent_summary(request, response, id): + delivery = Delivery.load(id) + date = delivery.to_date.strftime("%Y-%m-%d") + if not request['user'].is_referent(delivery): + return + referent = request['user'].email + producers = delivery.get_producers_for_referent(referent) + summary = reports.summary(delivery, producers) + response.xlsx(summary, filename=f"{config.SITE_NAME}-{date}-{referent}.xlsx") + + +@app.route("/livraison/{id}/product⋅eur⋅rice/{producer}/bon-de-commande", methods=["GET"]) async def download_producer_report(request, response, id, producer): delivery = Delivery.load(id) summary = reports.summary(delivery, [producer, ]) diff --git a/copanier/static/app.css b/copanier/static/app.css index d1ba7b9..7047838 100644 --- a/copanier/static/app.css +++ b/copanier/static/app.css @@ -558,4 +558,8 @@ details summary { border: 1px solid #ddd; padding: 10px 15px; resize: vertical; +} + +.email-template { + height: 400px; } \ No newline at end of file diff --git a/copanier/templates/prepare_referent_email.html b/copanier/templates/prepare_referent_email.html index c81c635..264a05f 100644 --- a/copanier/templates/prepare_referent_email.html +++ b/copanier/templates/prepare_referent_email.html @@ -6,12 +6,14 @@

-