Refactor e-mail generation and previewing

Review Request #8885 - Created April 6, 2017 and updated

Barret Rennie
Review Board
release-3.0.x
8897
reviewboard

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.

  • 1
  • 31
  • 4
  • 36
Description From Last Updated
local variable 'e' is assigned to but never used Review Bot Review Bot
Barret Rennie
Barret Rennie
Barret Rennie
Barret Rennie
Barret Rennie
Barret Rennie
Barret Rennie
Barret Rennie
Barret Rennie
Barret Rennie
David Trowbridge
Barret Rennie
David Trowbridge
Barret Rennie
Christian Hammond
Barret Rennie
Review request changed

Checks run (1 failed, 1 succeeded, 1 failed with error)

JSHint passed.
PEP8 Style Checker internal error.
Pyflakes failed.

Pyflakes

Loading...