0001-emails-use-new-default_sender_name-variable-set-from.patch
tests/test_workflows.py | ||
---|---|---|
1245 | 1245 |
assert emails.count() == 1 |
1246 | 1246 |
assert emails.get('foobar').get('from') == 'foobar@localhost' |
1247 | 1247 | |
1248 |
# custom sender name defined from site-options variable |
|
1249 |
pub.load_site_options() |
|
1250 |
if not pub.site_options.has_section('variables'): |
|
1251 |
pub.site_options.add_section('variables') |
|
1252 |
pub.site_options.set('variables', 'email_sender_name', 'SENDER NAME') |
|
1253 |
emails.empty() |
|
1254 |
item.to = [role1.id] |
|
1255 |
item.custom_from = '="foobar@localhost"' |
|
1256 |
item.perform(formdata) |
|
1257 |
get_response().process_after_jobs() |
|
1258 |
assert emails.count() == 1 |
|
1259 |
assert emails.get('foobar')['msg']['From'] == 'SENDER NAME <foobar@localhost>' |
|
1260 | ||
1248 | 1261 | |
1249 | 1262 |
def test_email_django_escaping(pub, emails): |
1250 | 1263 |
formdef = FormDef() |
wcs/qommon/emails.py | ||
---|---|---|
292 | 292 |
if not email_from: |
293 | 293 |
email_from = '%s@%s' % (pwd.getpwuid(os.getuid())[0], socket.getfqdn()) |
294 | 294 | |
295 |
sitename = get_publisher().get_site_option('global_title', 'variables') |
|
296 |
if sitename: |
|
297 |
msg['From'] = formataddr((str(Header(sitename, encoding)), email_from)) |
|
295 |
sender_name = (get_publisher().get_site_option('email_sender_name', 'variables') or |
|
296 |
get_publisher().get_site_option('global_title', 'variables')) |
|
297 |
if sender_name: |
|
298 |
msg['From'] = formataddr((str(Header(sender_name, encoding)), email_from)) |
|
298 | 299 |
else: |
299 | 300 |
msg['From'] = email_from |
300 | 301 | |
301 |
- |