[views] Discard Subject primary view. Provide uicfg Brainomics primary view customization instead (related to #3340591)
authorVladimir Popescu <vladimir.popescu@logilab.fr>
Mon, 20 Jan 2014 11:43:00 +0000
changeset 627 f8f9f52a327b
parent 626 a95dafbddee4
child 628 71919d38338f
[views] Discard Subject 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 10:51:28 2014 +0000
+++ b/views/primary.py	Mon Jan 20 11:43:00 2014 +0000
@@ -102,61 +102,6 @@
         w(u'</div>')
 
 
-###############################################################################
-### SUBJECT ###################################################################
-###############################################################################
-class SubjectPrimaryView(BrainomicsPrimaryView):
-    __select__ = BrainomicsPrimaryView.__select__ & is_instance('Subject')
-
-    def render_entity_attributes(self, entity):
-        return [(self._cw._('Age'), entity.display_age_for_assessments()),
-                (self._cw._('Handedness'), entity.handedness),
-                (self._cw._('Gender'), entity.gender),]
-
-    def display_additional_header(self, entity):
-        scores = self._cw.execute('Any X WHERE S related_infos X, S eid %(e)s', {'e': entity.eid})
-        if scores:
-            self.w(u'<h3>%s</h3>' % self._cw._('Scores'))
-            self.wview('incontext', scores)
-        # Therapies
-        therapies = self._cw.execute('Any X WHERE S related_therapies X, S eid %(e)s',
-                                     {'e': entity.eid})
-        if therapies:
-            self.w(u'<h3>%s</h3>' % xml_escape(self._cw._('Therapy_plural')))
-            self.wview('incontext', therapies)
-        # Diseases
-        diseases = self._cw.execute('Any X WHERE S related_diseases X, S eid %(e)s',
-                                     {'e': entity.eid})
-        if diseases:
-            self.w(u'<h3>%s</h3>' % xml_escape(self._cw._('Disease_plural')))
-            self.wview('incontext', diseases)
-
-
-    def iterate_data(self, entity):
-        data = []
-        for measure in MEASURES:
-            rql = 'Any X WHERE X is %s, X concerns S, S eid %s' % (measure, entity.eid)
-            data = self._build_data(data, rql, self._cw._(measure))
-        return data
-
-    def render_entity_relations(self, entity):
-        self.w(u'<div class="col-md-10">')
-        # Detailed measures
-        rset = self._cw.execute('Any X WHERE X concerns S, S eid %(e)s', {'e': entity.eid})
-        if rset:
-            self.w(u'<h3>%s</h3>' % xml_escape(self._cw._('Measures')))
-            self.wview('list', rset=rset)
-        self.w(u'</div>')
-        self.w(u'<div class="col-md-10">')
-        # Related external resources
-        rset = self._cw.execute('Any E WHERE X external_resources E, S concerned_by X, S eid %(e)s, '
-                                'NOT EXISTS(X generates M)', {'e': entity.eid})
-        if rset:
-            self.w(u'<h3>%s</h3>' % self._cw._('External Resources'))
-            self.wview('list', rset=rset)
-        self.w(u'</div>')
-
-
 ############################################################################
 ### STUDY ##################################################################
 ############################################################################
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/views/uicfg.py	Mon Jan 20 11:43:00 2014 +0000
@@ -0,0 +1,45 @@
+# -*- coding: utf-8 -*-
+# copyright 2014 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+# copyright 2014 CEA (Saclay, FRANCE), all rights reserved.
+# contact http://www.logilab.fr -- mailto:contact@logilab.fr
+#
+# This program is free software: you can redistribute it and/or modify it under
+# the terms of the GNU Lesser General Public License as published by the Free
+# Software Foundation, either version 2.1 of the License, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+# details.
+#
+# You should have received a copy of the GNU Lesser General Public License along
+# with this program. If not, see <http://www.gnu.org/licenses/>.
+
+"""cubicweb-suivimp views/forms/actions/components for web ui"""
+
+from cubicweb.web.views import uicfg
+
+_pvs = uicfg.primaryview_section
+_pvdc = uicfg.primaryview_display_ctrl
+
+
+###############################################################################
+### SUBJECT ###################################################################
+###############################################################################
+# XXX : For Subject, could not handle:
+#       - age_for_assessments(),
+#       - external_resources (Subject concerned_by X X external_resources E),
+#       - order of the attributes / relations.
+
+# Studies
+_pvs.tag_subject_of(('Subject', 'related_studies', 'Study'), 'attributes')
+# Related therapies
+_pvs.tag_subject_of(('Subject', 'related_therapies', 'Therapy'), 'attributes')
+# Related diseases
+_pvs.tag_subject_of(('Subject', 'related_diseases', 'Disease'), 'attributes')
+# Measures
+_pvs.tag_object_of(('GenomicMeasure', 'concerns', 'Subject'), 'relations')
+_pvdc.tag_object_of(('GenomicMeasure', 'concerns', 'Subject'),
+                      {'vid': 'outofcontext',
+                       'label': _('Measures')})