~edwargix/git.sr.ht

8c0ff9e78c3308406360a30028afdf1ab4a4ff01 — Drew DeVault 6 years ago 7c1d43a
Fix commentary not making it to the final email
2 files changed, 11 insertions(+), 3 deletions(-)

M gitsrht/blueprints/email.py
M gitsrht/templates/send-email-end.html
M gitsrht/blueprints/email.py => gitsrht/blueprints/email.py +10 -2
@@ 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()

M gitsrht/templates/send-email-end.html => gitsrht/templates/send-email-end.html +1 -1
@@ 102,7 102,7 @@
          <textarea
            class="form-control"
            rows="4"
            name="commentary-{{len(diffs) - loop.index}}"
            name="commentary_{{len(diffs) - loop.index}}"
          ></textarea>
        </details>
      </div>