fix patches repo mess
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Fri, 05 Aug 2011 13:34:22 +0200
changeset 6 76cb4680f2af
parent 5 df393d72f0d4
child 7 fe416ee3cf81
fix patches repo mess
astreampart.diff
series
--- a/astreampart.diff	Thu Aug 04 17:31:06 2011 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,155 +0,0 @@
-# HG changeset patch
-# User Sylvain Thénault <sylvain.thenault@logilab.fr>
-# Parent ec728e052d43c4ef34ba62fbbdfa4e53e5c559b3
-propose a more flexible implementation
-
-diff --git a/entities.py b/entities.py
---- a/entities.py
-+++ b/entities.py
-@@ -11,45 +11,93 @@
- # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
- # details.
- #
- # You should have received a copy of the GNU Lesser General Public License along
- # with this program. If not, see <http://www.gnu.org/licenses/>.
-+"""cubicweb-astream adapters"""
- 
--"""cubicweb-astream entity's classes"""
- from cubicweb.selectors import is_instance
- from cubicweb.view import EntityAdapter
-+from cubicweb.appobject import AppObject
- 
- class IActivityStreamAdapter(EntityAdapter):
-     __regid__ = 'IActivityStream'
- 
-     @property
--    def rql(self):
--        raise NotImplementedError()
-+    def astream_rql(self):
-+        """return a RQL query to get the whole activity stream of the adapted
-+        entity.
-+
-+        In this query, %(x)s will refer to the eid of the adapted entity. The
-+        returned query is expected to select:
-+
-+        1. the eid of the activity
-+        2. its date
-+        3. the actor of the activity
-+        4. some content.
-+
-+        and to be ordered on date (descending)
-+        """
-+        rqls = []
-+        for part in self._cw.vreg['astream'].possible_objects(
-+            self._cw, entity=self.entity):
-+            rqls += part.astream_rqls
-+        assert rqls, 'no activity stream for %s' % self.entity
-+        if len(rqls) > 1:
-+            rql =  ' UNION '.join('(%s)' % rql for rql in rqls)
-+        else:
-+            rql = rqls[0]
-+        return 'Any X,XD,XA,XC ORDERBY XD DESC WITH X,XD,XA,XC BEING (%s)' % rql
-+
-+
-+class ActivityStreamPart(AppObject):
-+    __registry__ = 'astream'
-+
-+    @property
-+    def astream_rqls(self):
-+        """return a list of RQL queries to get some path of the activity stream
-+        of the adapted entity.
-+
-+        In each query, %(x)s will refer to the eid of the adapted entity. The
-+        returned query is expected to select:
-+
-+        1. the eid of the activity
-+        2. its date
-+        3. the actor of the activity
-+        4. some content.
-+
-+        and should not be ordered.
-+        """
-+        raise NotImplementedError
-+
-+
-+class StatefulAStreamPart(ActivityStreamPart):
-+    __select__ = adaptable('IWorkflowable')
-+    __regid__ = 'stateful'
-+    astream_rqls = (
-+        'Any TI,TICD,U,TIC WHERE TI is TrInfo, TI wf_info_for X, X eid %(x)s,'
-+        'TI creation_date TICD, TI created_by U?, TI comment TIC',)
-+
- 
- class IActivityStreamItemAdapter(EntityAdapter):
-     __regid__ = 'IActivityStreamItem'
--
--    @property
--    def content(self):
--        raise NotImplementedError()
--
--    @property
--    def date(self):
--        raise NotImplementedError()
--
--class AnyAStreamItemAdapter(IActivityStreamItemAdapter):
-     __select__ = is_instance('Any')
- 
-     @property
-     def content(self):
-         return u'%s %s added' % (self.entity.e_schema, self.entity.dc_title())
- 
-     @property
-     def date(self):
-         return self.entity.creation_date
- 
--class TrinfoAStreamItemAdapter(AnyAStreamItemAdapter):
-+    @property
-+    def actor(self):
-+        return self.entity.dc_creator()
-+
-+
-+class TrinfoAStreamItemAdapter(IActivityStreamItemAdapter):
-     __select__ = is_instance('TrInfo')
- 
-     @property
-     def content(self):
-         return (u'%s %s transition from state %s to state %s with comment %s'
-diff --git a/views.py b/views.py
---- a/views.py
-+++ b/views.py
-@@ -2,30 +2,30 @@ from cubicweb.selectors import is_instan
- from cubicweb.view import EntityView
- 
- class AStreamView(EntityView):
-     __regid__ = 'activitystream'
-     __select__ = EntityView.__select__ & adaptable('IActivityStream')
-+    title = _('activitystream')
- 
-     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('IActivityStreamItem')
-         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))
--
--
-+               u'</div>' % (activity.actor, activity.content,
-+                            entity.absolute_url(),
-+                            self._cw.format_date(activity.date, time=True)))
--- a/series	Thu Aug 04 17:31:06 2011 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-astreampart.diff