Commit c97346d9 authored by Nicolas Chauvat's avatar Nicolas Chauvat
Browse files

refactor to make things simpler

parent cde4144526cb
......@@ -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 @@ class AnyAStreamAdapter(IActivityStreamAdapter):
@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'),
))
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):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment