[views] Discard ScoreDefinition primary view. Provide uicfg Brainomics primary view customization instead (related to #3340591)
authorVladimir Popescu <vladimir.popescu@logilab.fr>
Mon, 20 Jan 2014 11:50:53 +0000
changeset 633 dc13d1bf2681
parent 632 67122faaf6f3
child 634 f3d780ff56a1
[views] Discard ScoreDefinition 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 11:48:44 2014 +0000
+++ b/views/primary.py	Mon Jan 20 11:50:53 2014 +0000
@@ -124,57 +124,6 @@
 
 
 ###############################################################################
-### SCOREDEF ##################################################################
-###############################################################################
-class ScoreDefinitionPrimaryView(BrainomicsPrimaryView):
-    __select__ = BrainomicsPrimaryView.__select__ & is_instance('ScoreDefinition')
-
-    def render_entity_attributes(self, entity):
-        return [(self._cw._('Name'), entity.name),
-                (self._cw._('Category'), entity.category),
-                (self._cw._('Type'), entity.type),
-                (self._cw._('Unit'), entity.unit),
-                (self._cw._('Possible values'), entity.possible_values)
-               ]
-
-    def render_entity_relations(self, entity):
-        # Scores
-        w = self.w
-        rset = self._cw.execute('Any S,V,T,DA WHERE S is ScoreValue, S value V, S text T, '
-                                'S datetime DA, S definition D, D eid %(e)s', {'e': entity.eid})
-        if not rset:
-            return
-        w(u'<table class="table table-striped table-bordered table-condensed">')
-        w(u'<tr><th>%s</th><th>%s</th><th>%s</th></tr>'
-          % (self._cw._('Subject'), self._cw._('value'), self._cw._('datetime')))
-        # Warm subjects
-        score = rset.get_entity(0, 0)
-        if score.reverse_related_infos:
-            subjects_rset = self._cw.execute('Any SB, S, I WHERE S is ScoreValue, '
-                                             'SB related_infos S, SB identifier I, '
-                                             'S definition D, D eid %(e)s', {'e': entity.eid})
-        else:
-            # Measure/concerns
-            subjects_rset = self._cw.execute('Any SB, S, I WHERE S is ScoreValue, '
-                                             'S measure M, M concerns SB, SB identifier I, '
-                                             'S definition D, D eid %(e)s', {'e': entity.eid})
-        subjects = {}
-        for ind, e in enumerate(subjects_rset.entities()):
-            subjects[subjects_rset[ind][1]] = e
-        # Plot results
-        for ind in range(len(rset)):
-            score = rset.get_entity(ind, 0)
-            subj = subjects[score.eid]
-            if subj:
-                subject = u'<a href="%s">%s</a>' % (subj.absolute_url(), subj.identifier)
-            else:
-                subject = u'<unknown - error>'
-            w(u'<tr><th>%s</th><th>%s</th><th>%s</th></tr>'
-              % (subject, score.complete_value, score.datetime or '-'))
-        w(u'</table>')
-
-
-###############################################################################
 ### GENERIC TEST RUN ##########################################################
 ###############################################################################
 class GenericTestRunPrimaryView(BrainomicsPrimaryView):
--- a/views/uicfg.py	Mon Jan 20 11:48:44 2014 +0000
+++ b/views/uicfg.py	Mon Jan 20 11:50:53 2014 +0000
@@ -108,3 +108,12 @@
 _pvs.tag_subject_of(('Assessment', 'uses', '*'), 'relations')
 _pvdc.tag_subject_of(('Assessment', 'uses', '*'),
                      {'vid': 'outofcontext', 'label': _('Used measures')})
+
+
+###############################################################################
+### SCOREDEFINITION ###########################################################
+###############################################################################
+_pvs.tag_object_of(('ScoreValue', 'definition', 'ScoreDefinition'), 'relations')
+_pvdc.tag_object_of(('ScoreValue', 'definition', 'ScoreDefinition'),
+                    {'vid': 'scorevalue-incontext-table-view', 'label': _('Scores')})
+