Skip to content
Snippets Groups Projects
Commit 7324eccb0915 authored by Sylvain Thénault's avatar Sylvain Thénault
Browse files

use sender from headers if no more linked

parent 56f5e28bb201
No related branches found
No related tags found
No related merge requests found
......@@ -4,7 +4,6 @@
:copyright: 2003-2009 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
"""
__docformat__ = "restructuredtext en"
import re
......
......@@ -4,6 +4,8 @@
:copyright: 2003-2009 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
"""
__docformat__ = "restructuredtext en"
_ = unicode
from logilab.mtconverter import html_escape
......@@ -25,7 +27,17 @@
uicfg.actionbox_appearsin_addmenu.tag_object_of(('EmailThread', 'forked_from', 'EmailThread'),
True)
def formated_sender(email):
if email.sender:
return email.sender[0].view('oneline')
# sender address has been removed, look in email's headers
message = email.umessage_headers()
if message:
return html_escape(message.get('From'))
return email.req._('unknown sender')
class EmailPrimaryView(primary.PrimaryView):
__select__ = implements('Email')
def render_entity_attributes(self, entity):
......@@ -28,8 +40,8 @@
class EmailPrimaryView(primary.PrimaryView):
__select__ = implements('Email')
def render_entity_attributes(self, entity):
self.field('from', entity.sender[0].view('oneline'))
self.field('from', formated_sender(entity))
self.field('to', ', '.join(ea.view('oneline') for ea in entity.recipients))
if entity.cc:
self.field('cc', ', '.join(ea.view('oneline') for ea in entity.cc))
......@@ -74,5 +86,4 @@
def cell_call(self, row, col, contexteid=None):
entity = self.entity(row, col)
sender = entity.sender[0]
self.w(u'<div class="email">')
......@@ -78,5 +89,6 @@
self.w(u'<div class="email">')
self.w(u'<i>%s&nbsp;%s</i> '
% (self.req._('email_date'), self.format_date(entity.date, time=True)))
if contexteid != sender.eid:
self.w(u'<i>%s&nbsp;%s</i> ' % (
self.req._('email_date'), self.format_date(entity.date, time=True)))
sender = entity.senderaddr
if sender is None or contexteid != sender.eid:
self.w(u'<b>%s</b>&nbsp;%s '
......@@ -82,6 +94,6 @@
self.w(u'<b>%s</b>&nbsp;%s '
% (self.req._('email_from'), sender.view('oneline')))
% (self.req._('email_from'), formated_sender(entity)))
if contexteid not in (r.eid for r in entity.recipients):
recipients = ', '.join(r.view('oneline') for r in entity.recipients)
self.w(u'<b>%s</b>&nbsp;%s'
% (self.req._('email_to'), recipients))
......@@ -84,9 +96,9 @@
if contexteid not in (r.eid for r in entity.recipients):
recipients = ', '.join(r.view('oneline') for r in entity.recipients)
self.w(u'<b>%s</b>&nbsp;%s'
% (self.req._('email_to'), recipients))
self.w(u'<br/>\n<a href="%s">%s</a>'
% (html_escape(entity.absolute_url()), html_escape(entity.subject)))
self.w(u'<br/>\n<a href="%s">%s</a>' % (
html_escape(entity.absolute_url()), html_escape(entity.subject)))
self.w(u'</div>')
......@@ -95,6 +107,7 @@
id = 'outofcontext'
title = _('out of context')
class EmailInContextView(EmailOneLineView):
"""short view inside the context of the email"""
id = 'incontext'
......@@ -115,6 +128,7 @@
item_vid = 'outofcontext'
class EmailThreadPrimaryView(primary.PrimaryView):
__select__ = implements('EmailThread')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment