views.py 785 Bytes
Newer Older
Nicolas Chauvat's avatar
Nicolas Chauvat committed
1
2
3
4
from cubicweb.selectors import is_instance, adaptable
from cubicweb.view import EntityView

class AStreamView(EntityView):
5
    __regid__ = 'activitystream'
Nicolas Chauvat's avatar
Nicolas Chauvat committed
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
    __select__ = EntityView.__select__ & adaptable('IActivityStream')

    def cell_call(self, row, col):
        self._cw.add_css('cubes.astream.css')
        entity = self.cw_rset.get_entity(row, col)
        ablock = entity.dc_creator()
        activity = entity.cw_adapt_to('IActivityStream')
        self.w(u'<div class="activitystream">'
               u'<span class="author">%s</span>'
               u'<span class="msgtxt">%s</span>'
               u'<span class="meta"><a href="%s">%s</a></span>'
               u'</div>' % (ablock, activity.content,
                            entity.absolute_url(), activity.date))