Refactor e-mail generation and previewing

Review Request #8885 — Created April 6, 2017 and submitted — Latest diff uploaded

Information

Review Board
release-3.0.x

Reviewers

Previously e-mail generation and previewing used duplicated logic. The
preview_{foo}_email views would duplicate the logic used to generate
the template context that the mail_{foo} methods (that actually built
& sent the e-mails out).

Now, we have utilities for building e-mail messages
(prepare_{foo}_mail) that generate an EMailMessage but do not send
it and a generic e-mail sending & error-handling utility in
send_email. The logic for catching failed e-mails was present in each
method that sent an e-mail and it is now unified in a single place.

Additionally, we have a decorator that generates e-mail preview views
from functions that can generate the necessary arguments to provide to a
prepare_{foo}_email. This way the view only needs to compute the state
necessary, which has resulted in a large amount of deduplication.

Unit tests have been updated to reference the new methods.

Ran unit tests.

    Loading...