[views] Discard Assessment primary view. Provide uicfg Brainomics primary view customization instead (related to #3340591)
authorVladimir Popescu <vladimir.popescu@logilab.fr>
Mon, 20 Jan 2014 11:41:32 +0000
changeset 631 06368232fa3e
parent 630 47911e3b35bc
child 632 67122faaf6f3
[views] Discard Assessment 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:45:13 2014 +0000
+++ b/views/primary.py	Mon Jan 20 11:41:32 2014 +0000
@@ -123,42 +123,6 @@
             self.wview('list', rset)
 
 
-############################################################################
-### ASSESSMENT #############################################################
-############################################################################
-class AssessmentPrimaryView(BrainomicsPrimaryView):
-    __select__ = BrainomicsPrimaryView.__select__ & is_instance('Assessment')
-
-    def render_entity_attributes(self, entity):
-        subject = entity.reverse_concerned_by[0]
-        subject = u'<a href="%s">%s</a>' % (subject.absolute_url(), subject.dc_title())
-        return [(self._cw._('Identifier'), entity.identifier),
-                (self._cw._('Protocol'), entity.protocols),
-                (self._cw._('Date'), entity.datetime),
-                (self._cw._('Subject'), subject),
-                (self._cw._('Study'), entity.related_study[0].view('outofcontext')),
-                (self._cw._('Center'), entity.reverse_holds[0].view('outofcontext')),
-                ]
-
-    def iterate_data(self, entity):
-        data = []
-        # Generated
-        rset = self._cw.execute('Any M, COUNT(S) GROUPBY M WHERE X generates S, X eid %s, '
-                                'S is E, E name M' % entity.eid)
-        for m, count in rset:
-            rql = 'Any S WHERE X generates S, S is %s, X eid %s' % (m, entity.eid)
-            data = self._build_data(data, rql, self._cw._('Generated %(s)s' % {'s': m}))
-        # Used
-        rset = self._cw.execute('Any M, COUNT(S) GROUPBY M WHERE X uses S, X eid %s, '
-                                'S is E, E name M' % entity.eid)
-        for m, count in rset:
-            rql = 'Any S WHERE X uses S, S is %s, X eid %s' % (m, entity.eid)
-            data = self._build_data(data, rql, self._cw._('Used %(s)s' % {'s': m}))
-        return data
-
-    def render_entity_relations(self, entity):
-        pass
-
 ###############################################################################
 ### SCOREDEF ##################################################################
 ###############################################################################
--- a/views/uicfg.py	Mon Jan 20 11:45:13 2014 +0000
+++ b/views/uicfg.py	Mon Jan 20 11:41:32 2014 +0000
@@ -89,3 +89,22 @@
 # Measures
 _pvdc.tag_object_of(('*', 'uses_device', 'Device'),
                     {'label': _('Generated measures'), 'vid': 'outofcontext'})
+
+
+###############################################################################
+### ASSESSMENT ################################################################
+###############################################################################
+# XXX : for Assessment: cannot:
+#       - get the object type and put it into the 'label'
+#       - make synthetic counted table, via COUNT
+# Protocol
+_pvs.tag_subject_of(('Assessment', 'protocols', 'Protocol'), 'attributes')
+# Subject
+_pvs.tag_object_of(('Subject', 'concerned_by', 'Assessment'), 'attributes')
+# Measures
+_pvs.tag_subject_of(('Assessment', 'generates', '*'), 'relations')
+_pvdc.tag_subject_of(('Assessment', 'generates', '*'),
+                     {'vid': 'outofcontext', 'label': _('Generated measures')})
+_pvs.tag_subject_of(('Assessment', 'uses', '*'), 'relations')
+_pvdc.tag_subject_of(('Assessment', 'uses', '*'),
+                     {'vid': 'outofcontext', 'label': _('Used measures')})