[view] Add outofcontext view
authorVincent Michel <vincent.michel@logilab.fr>
Tue, 11 Dec 2012 18:43:01 +0100
changeset 13 e5efe62c12c4
parent 12 f692e9e76067
child 14 53b48188bfbf
[view] Add outofcontext view
views/outofcontext.py
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/views/outofcontext.py	Tue Dec 11 18:43:01 2012 +0100
@@ -0,0 +1,25 @@
+from cubicweb.view import AnyRsetView, EntityView
+from cubicweb.selectors import is_instance
+
+###############################################################################
+### VIEWS #####################################################################
+###############################################################################
+class SubjectOutOfContextView(EntityView):
+    __regid__ = 'outofcontext'
+    __select__ = EntityView.__select__ & is_instance('Subject')
+
+    def cell_call(self, row, col):
+        entity = self.cw_rset.get_entity(row, col)
+        self.w(u'<div class="thumbnail row-fluid">')
+        self.w(u'<div class="span2">')
+        self.w(u'<h1>%s</h1>' % entity.symbol)
+        self.w(u'</div>')
+        self.w(u'<div class="span8">')
+        self.w(u'<h4><a href="%s">%s</a></h4>' % (entity.absolute_url(), entity.dc_title()))
+        self.w(u'<div class="row-fluid">')
+        self.w(u'Age <em>%s</em>' % entity.age)
+        self.w(u' - ')
+        self.w(u'Handedness <em>%s</em>' % entity.handedness)
+        self.w(u'</div>')
+        self.w(u'</div>')
+        self.w(u'</div>')