refactor to make things simpler
authorNicolas Chauvat <nicolas.chauvat@logilab.fr>
Wed, 22 Jun 2011 12:36:19 +0200
changeset 1 fbaceb1c1f9f
parent 0 cde4144526cb
child 2 ec728e052d43
refactor to make things simpler
entities.py
views.py
--- a/entities.py	Tue Jun 21 21:13:57 2011 +0200
+++ b/entities.py	Wed Jun 22 12:36:19 2011 +0200
@@ -16,7 +16,18 @@
 
 """cubicweb-astream entity's classes"""
 from cubicweb.selectors import is_instance
-from cubes.astream.views import IActivityStreamAdapter
+from cubicweb.view import EntityAdapter
+
+class IActivityStreamAdapter(EntityAdapter):
+    __regid__ = 'IActivityStream'
+
+    @property
+    def content(self):
+        raise NotImplementedError()
+
+    @property
+    def date(self):
+        raise NotImplementedError()
 
 class AnyAStreamAdapter(IActivityStreamAdapter):
     __select__ = is_instance('Any')
@@ -28,3 +39,16 @@
     @property
     def date(self):
         return self.entity.creation_date
+
+class TrinfoAStreamAdapter(AnyAStreamAdapter):
+    __select__ = is_instance('TrInfo')
+
+    @property
+    def content(self):
+        return (u'%s %s transition from state %s to state %s with comment %s'
+                % (self.entity.wf_info_for[0].e_schema,
+                   self.entity.wf_info_for[0].dc_title(),
+                   self.entity.from_state[0].name,
+                   self.entity.to_state[0].name,
+                   self.entity.printable_value('comment'),
+                   ))
--- a/views.py	Tue Jun 21 21:13:57 2011 +0200
+++ b/views.py	Wed Jun 22 12:36:19 2011 +0200
@@ -1,37 +1,8 @@
 from cubicweb.selectors import is_instance, adaptable
 from cubicweb.view import EntityView
-from cubicweb.view import EntityAdapter
-
-class IActivityStreamAdapter(EntityAdapter):
-    __regid__ = 'IActivityStream'
-
-    @property
-    def content(self):
-        raise NotImplementedError()
-
-    @property
-    def date(self):
-        raise NotImplementedError()
-
-class TrinfoAStreamAdapter(IActivityStreamAdapter):
-    __select__ = is_instance('TrInfo')
-
-    @property
-    def content(self):
-        return (u'%s %s transition from state %s to state %s with comment %s'
-                % (self.entity.wf_info_for[0].e_schema,
-                   self.entity.wf_info_for[0].dc_title(),
-                   self.entity.from_state[0].name,
-                   self.entity.to_state[0].name,
-                   self.entity.printable_value('comment'),
-                   ))
-
-    @property
-    def date(self):
-        return self.entity.creation_date
 
 class AStreamView(EntityView):
-    __regid__ = 'astream'
+    __regid__ = 'activitystream'
     __select__ = EntityView.__select__ & adaptable('IActivityStream')
 
     def cell_call(self, row, col):