Commit 661db186 authored by sylvain.thenault@logilab.fr's avatar sylvain.thenault@logilab.fr
Browse files

3.2 update, delete-trailing-whitespaces

parent f705df9fc4a3
......@@ -25,33 +25,29 @@ class Email(TreeMixIn, AnyEntity):
__rtags__ = {'attachment' : 'create',
}
__implements__ = AnyEntity.__implements__ + (ITree,)
widgets = {
'subject' : "StringWidget",
}
tree_attribute = 'reply_to'
def parent(self):
"""for breadcrumbs"""
return self.thread
def dc_title(self):
return self.subject
@property
def senderaddr(self):
return self.sender[0]
@property
def in_reply_to(self):
return self.reply_to and self.reply_to[0]
@property
def thread(self):
return self.in_thread and self.in_thread[0]
def parts_in_order(self, prefered_mime_type='text/html'):
"""sort an email parts in order, selecting among alternatives according to a
prefered mime type
......@@ -96,7 +92,7 @@ class Email(TreeMixIn, AnyEntity):
lines_rgx = re.compile('^Lines:\s*\d+\s*\n', re.I|re.U|re.M)
clength_rgx = re.compile('^Content-Length:\s*\d+\s*\n', re.I|re.U|re.M)
ctype_rgx = re.compile('^Content-Type:[^:]', re.I|re.U|re.M)
def umessage_headers(self):
if not self.headers:
return None
......@@ -105,8 +101,8 @@ class Email(TreeMixIn, AnyEntity):
headers = self.ctype_rgx.sub('Content-type: text/plain; charset=utf8', headers)
headers = headers.encode('utf8')
return umessage.message_from_string(headers + '\n\n')
class EmailPart(AnyEntity):
"""customized class for EmailPart entities"""
id = 'EmailPart'
......@@ -114,25 +110,25 @@ class EmailPart(AnyEntity):
def dc_title(self):
return '%s (%s %s)' % (self.email.subject,
self.req._('part'), self.ordernum)
@property
def email(self):
return self.reverse_parts[0]
def parent(self):
"""for breadcrumbs"""
return self.email
def actual_content(self):
"""return content of this part with citations and signature removed
this method may raise `TransformError` exception if the part can't
be displayed as text/plain.
"""
content = self.printable_value('content', format='text/plain')
content = self.printable_value('content', format='text/plain')
return parse_body(content).actual_content
class EmailThread(AnyEntity):
"""customized class for EmailThread entities"""
id = 'EmailThread'
......
......@@ -10,12 +10,14 @@ from logilab.mtconverter import html_escape
from cubicweb.selectors import implements
from cubicweb.common.uilib import soup2xhtml
from cubicweb.common.mixins import TreeViewMixIn
from cubicweb.web import uicfg
from cubicweb.web import uicfg, formwidgets
from cubicweb.web.views import baseviews, primary
for rtype in ('sender', 'recipients', 'cc', 'parts'):
uicfg.rdisplay.tag_relation({}, ('Email', rtype, '*'), 'subject')
uicfg.rwidgets.tag_attribute(formwidgets.TextInput, 'Email', 'subject')
class EmailPrimaryView(primary.PrimaryView):
__select__ = implements('Email')
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment