Allow global_merge_vars to be merged in with the per message dict, with keys in the latter taking precedent.

Update the docs accordingly.
This commit is contained in:
William Hector
2015-07-14 05:57:12 +01:00
parent 883b23362c
commit 7179734a08
4 changed files with 28 additions and 4 deletions

View File

@@ -285,12 +285,17 @@ class DjrillBackend(BaseEmailBackend):
# Allow simple python dicts in place of Mandrill
# [{name:name, value:value},...] arrays...
# Allow merge of global and per message global_merge_var, the former taking precedent
global_merge_vars = {}
if 'global_merge_vars' in self.global_settings:
msg_dict['global_merge_vars'] = self._expand_merge_vars(
self.global_settings['global_merge_vars'])
global_merge_vars.update(self.global_settings['global_merge_vars'])
if hasattr(message, 'global_merge_vars'):
global_merge_vars.update(message.global_merge_vars)
if global_merge_vars:
msg_dict['global_merge_vars'] = \
self._expand_merge_vars(message.global_merge_vars)
self._expand_merge_vars(global_merge_vars)
if hasattr(message, 'merge_vars'):
# For testing reproducibility, we sort the recipients
msg_dict['merge_vars'] = [