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

3.2 updates

parent 4b12ea2f44ee
......@@ -23,7 +23,7 @@ from cubicweb.sobjects.notification import parse_message_id
def fix_ownership(session, eid, email):
sender = email.senderaddr.email_of
if (sender and sender.e_schema == 'EUser' and
if (sender and sender.e_schema == 'CWUser' and
sender.eid != session.actual_session().user.eid):
# match a user which is not the session's user, set owned_by / created_by
session.unsafe_execute('SET X owned_by U WHERE X eid %(x)s, U eid %(u)s',
......
......@@ -47,7 +47,7 @@ class ChangeStateHooksTC(EnvBasedTC):
def test_email_change_state(self):
u = self.execute('INSERT EUser X: X login "toto", X upassword "sosafe", X in_group G, X in_state S '
u = self.execute('INSERT CWUser X: X login "toto", X upassword "sosafe", X in_group G, X in_state S '
'WHERE G name "users", S name "activated"').get_entity(0, 0)
subject = u':deactivate: %s' % u.eid
eeid = self.execute('INSERT Email X: '
......@@ -62,7 +62,7 @@ class ChangeStateHooksTC(EnvBasedTC):
def test_email_change_state_trinfo_owner(self):
self.execute('SET U use_email E WHERE U login "anon"')
u = self.execute('INSERT EUser X: X login "toto", X upassword "sosafe", X in_group G, X in_state S '
u = self.execute('INSERT CWUser X: X login "toto", X upassword "sosafe", X in_group G, X in_state S '
'WHERE G name "users", S name "activated"').get_entity(0, 0)
subject = u':deactivate: %s' % u.eid
eeid = self.execute('INSERT Email X: '
......@@ -76,7 +76,7 @@ class ChangeStateHooksTC(EnvBasedTC):
self.assertEquals(u.latest_trinfo().creator.login, 'anon')
def test_email_change_state_wrong_eid(self):
ueid = self.execute('INSERT EUser X: X login "toto", X upassword "sosafe", X in_group G, X in_state S '
ueid = self.execute('INSERT CWUser X: X login "toto", X upassword "sosafe", X in_group G, X in_state S '
'WHERE G name "users", S name "activated"')[0][0]
subject = u':deactivate: %s' % 10
eeid = self.execute('INSERT Email X: '
......@@ -89,7 +89,7 @@ class ChangeStateHooksTC(EnvBasedTC):
self.assertEquals(userstate, 'activated')
def test_email_change_state_unexistant_eid(self):
ueid = self.execute('INSERT EUser X: X login "toto", X upassword "sosafe", X in_group G, X in_state S '
ueid = self.execute('INSERT CWUser X: X login "toto", X upassword "sosafe", X in_group G, X in_state S '
'WHERE G name "users", S name "activated"')[0][0]
subject = u':deactivate: %s' % 999999
eeid = self.execute('INSERT Email X: '
......@@ -102,7 +102,7 @@ class ChangeStateHooksTC(EnvBasedTC):
self.assertEquals(userstate, 'activated')
def test_email_change_state_unexistant_transition(self):
ueid = self.execute('INSERT EUser X: X login "toto", X upassword "sosafe", X in_group G, X in_state S '
ueid = self.execute('INSERT CWUser X: X login "toto", X upassword "sosafe", X in_group G, X in_state S '
'WHERE G name "users", S name "activated"')[0][0]
subject = u':blabla: %s' % ueid
eeid = self.execute('INSERT Email X: '
......
"""Specific views for email related entities
:organization: Logilab
:copyright: 2003-2008 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
:copyright: 2003-2009 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
"""
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.views import baseviews
from cubicweb.web import uicfg
from cubicweb.web.views import baseviews, primary
for rtype in ('sender', 'recipients', 'cc', 'parts'):
uicfg.rdisplay.tag_relation({}, ('Email', rtype, '*'), 'subject')
class EmailPrimaryView(baseviews.PrimaryView):
accepts = ('Email',)
skip_rels = ('sender', 'recipients', 'cc', 'parts', 'owned_by')
class EmailPrimaryView(primary.PrimaryView):
__select__ = implements('Email')
def render_entity_attributes(self, entity, siderelations):
def render_entity_attributes(self, entity):
self.field('from', entity.sender[0].view('oneline'))
self.field('to', ', '.join(ea.view('oneline') for ea in entity.recipients))
if entity.cc:
......@@ -34,36 +37,32 @@ class EmailPrimaryView(baseviews.PrimaryView):
# XXX some headers to skip if html ?
self.w(content)
self.w(u'<br class="partseparator"/>')
# def render_side_related(self, entity, siderelations):
# pass
def render_entity_title(self, entity):
self.w(u'<h1><span class="etype">%s</span> %s</h1>'
% (entity.dc_type().capitalize(), html_escape(entity.dc_title())))
class EmailHeadersView(baseviews.EntityView):
"""display email's headers"""
id = 'headers'
__select__ = implements('Email')
title = _('headers')
accepts = ('Email',)
templatable = False
content_type = 'text/plain'
def cell_call(self, row, col):
entity = self.entity(row, col)
self.w(entity.headers)
class EmailOneLineView(baseviews.PrimaryView):
class EmailOneLineView(baseviews.OneLineView):
"""short view usable in the context of the email sender/recipient (in which
case the caller should specify its context eid) or outside any context
"""
id = 'oneline'
__select__ = implements('Email')
title = _('oneline')
accepts = ('Email',)
def cell_call(self, row, col, contexteid=None):
entity = self.entity(row, col)
sender = entity.sender[0]
......@@ -81,10 +80,11 @@ class EmailOneLineView(baseviews.PrimaryView):
% (html_escape(entity.absolute_url()), html_escape(entity.subject)))
self.w(u'</div>')
class EmailOutOfContextView(EmailOneLineView):
"""short view outside the context of the email"""
id = 'outofcontext'
title = _('out of context')
title = _('out of context')
class EmailInContextView(EmailOneLineView):
"""short view inside the context of the email"""
......@@ -93,22 +93,22 @@ class EmailInContextView(EmailOneLineView):
class EmailPartOutOfContextView(baseviews.OutOfContextView):
"""out of context an email part is redirecting to related email view"""
accepts = ('EmailPart',)
__select__ = implements('EmailPart')
def cell_call(self, row, col):
entity = self.entity(row, col)
entity.reverse_parts[0].view('outofcontext', w=self.w)
class EmailThreadView(TreeViewMixIn, baseviews.ListView):
"""display email's headers"""
accepts = ('Email',)
__select__ = implements('Email')
title = _('thread view')
item_vid = 'outofcontext'
class EmailThreadPrimaryView(baseviews.PrimaryView):
accepts = ('EmailThread',)
__select__ = implements('EmailThread')
def cell_call(self, row, col):
entity = self.complete_entity(row, col)
self.w(u'<h1>%s</h1>' % html_escape(entity.title))
......@@ -132,5 +132,5 @@ class EmailThreadPrimaryView(baseviews.PrimaryView):
self.w(u'<ul>')
self.w(u'\n'.join(email.view('tree') for email in rset.entities()))
self.w(u'</ul>')
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