[views] Discard GenericTestRun primary view. Provide uicfg Brainomics primary view customization instead (related to #3340591)
authorVladimir Popescu <vladimir.popescu@logilab.fr>
Mon, 20 Jan 2014 13:01:00 +0000
changeset 635 4e95aeb78d9a
parent 634 f3d780ff56a1
child 636 6d08cddefb5d
[views] Discard GenericTestRun primary view. Provide uicfg Brainomics primary view customization instead (related to #3340591)
views/primary.py
views/uicfg.py
--- a/views/primary.py	Mon Jan 20 12:57:02 2014 +0000
+++ b/views/primary.py	Mon Jan 20 13:01:00 2014 +0000
@@ -103,51 +103,6 @@
 
 
 ###############################################################################
-### GENERIC TEST RUN ##########################################################
-###############################################################################
-class GenericTestRunPrimaryView(BrainomicsPrimaryView):
-    __select__ = BrainomicsPrimaryView.__select__ & is_instance('GenericTestRun')
-
-    def render_entity_attributes(self, entity):
-        test = entity.instance_of[0]
-        test = u'<a href="%s">%s</a>' % (test.absolute_url(), test.dc_title())
-        subject = entity.concerns[0]
-        subject = u'<a href="%s">%s</a>' % (subject.absolute_url(), subject.dc_title())
-        return [(self._cw._('Date'), entity.datetime),
-                (self._cw._('Instance of'), test),
-                (self._cw._('Subject'), subject),]
-
-    def render_entity_relations(self, entity):
-        w = self.w
-        # Scores
-        self.w(u'<div class="col-md-9">')
-        rset = self._cw.execute('Any SD, S WHERE QR is GenericTestRun, QR eid %(e)s, '
-                                'S measure QR, S definition SD, S value V, S text T',
-                                {'e': entity.eid})
-        w(u'<table class="table table-striped table-bordered table-condensed">')
-        w(u'<tr>')
-        for label in ('score', 'text/value'):
-                        w(u'<th>%s</th>' % self._cw._(label))
-        w(u'</tr>')
-        for ind, scoredef in enumerate(rset.entities()):
-            w(u'<tr>')
-            w(u'<th><a href="%s">%s</a></th>' % (scoredef.absolute_url(), scoredef.dc_title()))
-            w(u'<th>%s</th>' % (rset.get_entity(ind, 1).complete_value))
-            w(u'</tr>')
-        w(u'</table>')
-        self.w(u'</div>')
-        # Related external resources
-        self.w(u'<div class="col-md-3">')
-        rset = self._cw.execute('(Any E WHERE X external_resources E, X eid %(e)s) '
-                                'UNION (Any E WHERE A generates X, A external_resources E, X eid %(e)s)',
-                                {'e': entity.eid})
-        if rset:
-            w(u'<h3>%s</h3>' % self._cw._('External Resources'))
-            self.wview('list', rset=rset)
-        self.w(u'</div>')
-
-
-###############################################################################
 ### GENERIC TEST ##############################################################
 ###############################################################################
 class GenericTestPrimaryView(BrainomicsPrimaryView):
--- a/views/uicfg.py	Mon Jan 20 12:57:02 2014 +0000
+++ b/views/uicfg.py	Mon Jan 20 13:01:00 2014 +0000
@@ -124,3 +124,25 @@
 _pvs.tag_object_of(('Assessment', 'conducted_by', 'Investigator'), 'relations')
 _pvdc.tag_object_of(('Assessment', 'conducted_by', 'Investigator'),
                     {'vid': 'list', 'label': _('Assessments conducted by this investigator')})
+
+
+###############################################################################
+### GENERICTERUN ##############################################################
+###############################################################################
+# XXX : for GenericTestRun : could not:
+#       - handle ScoreDefinition, ScoreValue tuples in the same rset
+#       - handle indirect external_resources, i.e. A -- generates -- GenericTestRun and
+#         A -- external_resources -- E
+# Instance
+_pvs.tag_subject_of(('GenericTestRun', 'instance_of', '*'), 'attributes')
+# Concerns
+_pvs.tag_subject_of(('GenericTestRun', 'concerns', 'Subject'), 'attributes')
+# Measures
+_pvs.tag_object_of(('*', 'measure', 'GenericTestRun'), 'relations')
+_pvdc.tag_object_of(('*', 'measure', 'GenericTestRun'),
+                    {'vid': 'scorevalue-outofcontext-tableview',
+                     'label': _('score')})
+_pvdc.tag_subject_of(('GenericTestRun', 'external_resources', '*'),
+                     {'vid': 'list', 'label': _('External Resources')})
+
+