views.py 1.21 KB
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
    __select__ = EntityView.__select__ & adaptable('IActivityStream')

8
9
10
11
12
13
14
15
16
17
18
    def cell_call(self, row, col):
        entity = self.cw_rset.get_entity(row, col)
        rset = self._cw.execute(entity.cw_adapt_to('IActivityStream').rql,
                                dict(x=entity.eid))
        self.paginate(rset=rset)
        self.wview('activitystream_item', rset, 'null')

class AStreamItemView(EntityView):
    __regid__ = 'activitystream_item'
    __select__ = EntityView.__select__ & adaptable('IActivityStreamItem')

Nicolas Chauvat's avatar
Nicolas Chauvat committed
19
20
21
22
    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()
23
        activity = entity.cw_adapt_to('IActivityStreamItem')
Nicolas Chauvat's avatar
Nicolas Chauvat committed
24
25
26
27
28
29
30
31
        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))