Skip to content
Snippets Groups Projects
hooks.py 1.14 KiB
Newer Older
Nicolas Chauvat's avatar
Nicolas Chauvat committed
"""Comment notification hooks

:organization: Logilab
sylvain thenault's avatar
sylvain thenault committed
:copyright: 2003-2009 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
Nicolas Chauvat's avatar
Nicolas Chauvat committed
:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
"""
__docformat__ = "restructuredtext en"

from cubicweb import RegistryException
sylvain thenault's avatar
sylvain thenault committed
from cubicweb.selectors import implements
from cubicweb.sobjects import notification
sylvain thenault's avatar
sylvain thenault committed
class CommentAddedView(notification.NotificationView):
Nicolas Chauvat's avatar
Nicolas Chauvat committed
    """get notified from new comments"""
    id = 'notif_after_add_relation_comments'
sylvain thenault's avatar
sylvain thenault committed
    __select__ = implements('Comment',)
Nicolas Chauvat's avatar
Nicolas Chauvat committed
    msgid_timestamp = False

    def subject(self):
        root = self.entity(self.row, self.col).root()
        return '%s %s %s' % (self.req._('new comment for'),
                             root.dc_type(),
                             root.dc_title())
sylvain thenault's avatar
sylvain thenault committed

Nicolas Chauvat's avatar
Nicolas Chauvat committed
    def cell_call(self, row, col=0, **kwargs):
Arthur Lutz's avatar
Arthur Lutz committed
        self.cw_row, self.cw_col = row, col
Nicolas Chauvat's avatar
Nicolas Chauvat committed
        try:
Sylvain Thénault's avatar
Sylvain Thénault committed
            view = self.vreg['views'].select('fullthreadtext', self.req,
                                             rset=self.rset, row=row, col=col)
Nicolas Chauvat's avatar
Nicolas Chauvat committed
        except RegistryException:
            return
        return view.render(row=row, col=col, w=self.w, **kwargs)