[gen] appy.gen.mail.py: bugfix (management of recipients). When Config.userLink is False, still display the user name, but as non-clickable text.
This commit is contained in:
parent
f3849d4f92
commit
0465fae6dc
|
@ -46,6 +46,7 @@ def sendMail(config, to, subject, body, attachments=None, log=None):
|
||||||
|
|
||||||
p_log can be a function/method accepting a single string arg.
|
p_log can be a function/method accepting a single string arg.
|
||||||
'''
|
'''
|
||||||
|
if isinstance(to, str): to = [to]
|
||||||
if not config:
|
if not config:
|
||||||
if log: log('Must send mail but no smtp server configured.')
|
if log: log('Must send mail but no smtp server configured.')
|
||||||
return
|
return
|
||||||
|
@ -75,9 +76,6 @@ def sendMail(config, to, subject, body, attachments=None, log=None):
|
||||||
# Add the header values
|
# Add the header values
|
||||||
msg['Subject'] = Header(subject, 'utf-8')
|
msg['Subject'] = Header(subject, 'utf-8')
|
||||||
msg['From'] = fromAddress
|
msg['From'] = fromAddress
|
||||||
if isinstance(to, basestring):
|
|
||||||
msg['To'] = to
|
|
||||||
else:
|
|
||||||
if len(to) == 1:
|
if len(to) == 1:
|
||||||
msg['To'] = to[0]
|
msg['To'] = to[0]
|
||||||
else:
|
else:
|
||||||
|
@ -107,7 +105,7 @@ def sendMail(config, to, subject, body, attachments=None, log=None):
|
||||||
smtpServer = smtplib.SMTP(config.server, port=config.port)
|
smtpServer = smtplib.SMTP(config.server, port=config.port)
|
||||||
if config.login:
|
if config.login:
|
||||||
smtpServer.login(config.login, config.password)
|
smtpServer.login(config.login, config.password)
|
||||||
res = smtpServer.sendmail(fromAddress, [to], msg.as_string())
|
res = smtpServer.sendmail(fromAddress, to, msg.as_string())
|
||||||
smtpServer.quit()
|
smtpServer.quit()
|
||||||
if res and log:
|
if res and log:
|
||||||
log('could not send mail to some recipients. %s' % str(res),
|
log('could not send mail to some recipients. %s' % str(res),
|
||||||
|
|
|
@ -16,8 +16,9 @@ class UserWrapper(AbstractWrapper):
|
||||||
# Display, in the user strip, links to the User instance of the logged user.
|
# Display, in the user strip, links to the User instance of the logged user.
|
||||||
pxUserLink = Px('''
|
pxUserLink = Px('''
|
||||||
<td class="userStripText" align=":dright">
|
<td class="userStripText" align=":dright">
|
||||||
<a href=":user.url"><img src=":url('user')"/>
|
<a if="cfg.userLink" href=":user.url"><img src=":url('user')"/>
|
||||||
<span style="padding: 0 3px">:user.getTitle()</span></a>
|
<span style="padding: 0 3px">:user.getTitle()</span></a>
|
||||||
|
<x if="not cfg.userLink">:user.getTitle()</x>
|
||||||
</td>''')
|
</td>''')
|
||||||
|
|
||||||
def isSpecial(self): return self.login in self.specialUsers
|
def isSpecial(self): return self.login in self.specialUsers
|
||||||
|
|
|
@ -264,7 +264,7 @@ class AbstractWrapper(object):
|
||||||
<a href=":tool.url + '/performLogout'" title=":_('app_logout')">
|
<a href=":tool.url + '/performLogout'" title=":_('app_logout')">
|
||||||
<img src=":url('logout.gif')"/></a>
|
<img src=":url('logout.gif')"/></a>
|
||||||
</td>
|
</td>
|
||||||
<x if="cfg.userLink">:user.pxUserLink</x>
|
<x>:user.pxUserLink</x>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</td>
|
</td>
|
||||||
|
|
Loading…
Reference in a new issue