Refactor e-mail generation and previewing
Review Request #8885 — Created April 6, 2017 and submitted — Latest diff uploaded
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 themail_{foo}
methods (that actually built
& sent the e-mails out).Now, we have utilities for building e-mail messages
(prepare_{foo}_mail
) that generate anEMailMessage
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.
Changes between revision 1 and 2
reviewboard/templates/notifications/api_token_created.html |
---|
reviewboard/templates/notifications/api_token_created.txt |
---|
reviewboard/templates/notifications/api_token_deleted.html |
---|
reviewboard/templates/notifications/api_token_deleted.txt |
---|
reviewboard/templates/notifications/api_token_updated.html |
---|
reviewboard/templates/notifications/api_token_updated.txt |
---|
reviewboard/templates/notifications/email_base.html |
---|
reviewboard/templates/notifications/email_diff_comment_fragment.html |
---|
reviewboard/templates/notifications/new_user_email.html |
---|
reviewboard/templates/notifications/new_user_email.txt |
---|
reviewboard/templates/notifications/reply_email.html |
---|
reviewboard/templates/notifications/reply_email.txt |
---|
reviewboard/templates/notifications/review_email.html |
---|
reviewboard/templates/notifications/review_email.txt |
---|
reviewboard/templates/notifications/review_request_email.html |
---|
reviewboard/templates/notifications/review_request_email.txt |
---|