From 8c0ff9e78c3308406360a30028afdf1ab4a4ff01 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Mon, 14 Oct 2019 15:28:52 -0400 Subject: [PATCH] Fix commentary not making it to the final email --- gitsrht/blueprints/email.py | 12 ++++++++++-- gitsrht/templates/send-email-end.html | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/gitsrht/blueprints/email.py b/gitsrht/blueprints/email.py index 91695d4..f490219 100644 --- a/gitsrht/blueprints/email.py +++ b/gitsrht/blueprints/email.py @@ -154,7 +154,9 @@ def prepare_patchset(repo, git_repo, cover_letter=None, extra_headers=False, emails[0].set_payload(body) for i, email in enumerate(emails[(1 if cover_letter else 0):]): - commentary = valid.optional(f"commentary-{i}") + commentary = valid.optional(f"commentary_{i}") + if not commentary: + commentary = session.get(f"commentary_{i}") if not commentary: continue commentary = "\n".join(wrapper.wrap(commentary)) @@ -223,6 +225,11 @@ def send_email_review(owner, repo): commits=log, start=start, diffs=diffs, diffstat=diffstat, **valid.kwargs) + for i, email in enumerate(emails): + comm = valid.optional(f"commentary_{i}") + if comm: + session[f"commentary_{i}"] = comm + session["cover_letter"] = cover_letter return render_template("send-email-review.html", view="send-email", owner=owner, repo=repo, @@ -291,7 +298,8 @@ def send_email_send(owner, repo): smtp.starttls() smtp.login(smtp_user, smtp_password) print("Sending to receipients", recipients) - for email in emails: + for i, email in enumerate(emails): + session.pop("commentary_{i}", None) smtp.sendmail(smtp_user, recipients, email.as_bytes(unixfrom=False)) smtp.quit() diff --git a/gitsrht/templates/send-email-end.html b/gitsrht/templates/send-email-end.html index 03a308b..1eb83e4 100644 --- a/gitsrht/templates/send-email-end.html +++ b/gitsrht/templates/send-email-end.html @@ -102,7 +102,7 @@ -- 2.38.4