make difference between container and item
authorNicolas Chauvat <nicolas.chauvat@logilab.fr>
Thu, 04 Aug 2011 15:51:01 +0200
changeset 2 ec728e052d43
parent 1 fbaceb1c1f9f
child 3 9c6f2d721ae5
make difference between container and item
entities.py
views.py
--- a/entities.py	Wed Jun 22 12:36:19 2011 +0200
+++ b/entities.py	Thu Aug 04 15:51:01 2011 +0200
@@ -22,6 +22,13 @@
     __regid__ = 'IActivityStream'
 
     @property
+    def rql(self):
+        raise NotImplementedError()
+
+class IActivityStreamItemAdapter(EntityAdapter):
+    __regid__ = 'IActivityStreamItem'
+
+    @property
     def content(self):
         raise NotImplementedError()
 
@@ -29,7 +36,7 @@
     def date(self):
         raise NotImplementedError()
 
-class AnyAStreamAdapter(IActivityStreamAdapter):
+class AnyAStreamItemAdapter(IActivityStreamItemAdapter):
     __select__ = is_instance('Any')
 
     @property
@@ -40,7 +47,7 @@
     def date(self):
         return self.entity.creation_date
 
-class TrinfoAStreamAdapter(AnyAStreamAdapter):
+class TrinfoAStreamItemAdapter(AnyAStreamItemAdapter):
     __select__ = is_instance('TrInfo')
 
     @property
--- a/views.py	Wed Jun 22 12:36:19 2011 +0200
+++ b/views.py	Thu Aug 04 15:51:01 2011 +0200
@@ -6,10 +6,21 @@
     __select__ = EntityView.__select__ & adaptable('IActivityStream')
 
     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')
+
+    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')
+        activity = entity.cw_adapt_to('IActivityStreamItem')
         self.w(u'<div class="activitystream">'
                u'<span class="author">%s</span>'
                u'<span class="msgtxt">%s</span>'