Skip to content
Snippets Groups Projects
hooks.py 1.13 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):
        self.row, self.col = row, col
        try:
            view = self.vreg.select_view('fullthreadtext', self.req, self.rset,
                                         row=row, col=col)
        except RegistryException:
            return
        return view.render(row=row, col=col, w=self.w, **kwargs)