[views] Discard Center primary view. Provide uicfg Brainomics primary view customization instead (related to #3340591)
authorVladimir Popescu <vladimir.popescu@logilab.fr>
Mon, 20 Jan 2014 11:28:09 +0000
changeset 629 7ec6d3ca59b8
parent 628 71919d38338f
child 630 47911e3b35bc
[views] Discard Center 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:43:33 2014 +0000
+++ b/views/primary.py	Mon Jan 20 11:28:09 2014 +0000
@@ -122,38 +122,6 @@
         if rset:
             self.wview('list', rset)
 
-
-############################################################################
-### CENTER #################################################################
-############################################################################
-class CenterPrimaryView(BrainomicsPrimaryView):
-    __select__ = BrainomicsPrimaryView.__select__ & is_instance('Center')
-
-    def render_entity_attributes(self, entity):
-        return [(self._cw._('Identifier'), entity.identifier),
-                (self._cw._('Department'), entity.department),
-                (self._cw._('City'), entity.city),
-                (self._cw._('Country'), entity.country),]
-
-    def iterate_data(self, entity):
-        data = []
-        # Subjects
-        rql = 'DISTINCT Any S WHERE S is Subject, X holds A, S concerned_by A, X eid %s' % entity.eid
-        data = self._build_data(data, rql, self._cw._('Subjects'))
-        # Assessments
-        rql = 'DISTINCT Any A WHERE X holds A, X eid %s' % entity.eid
-        data = self._build_data(data, rql, self._cw._('Assessments'))
-        return data
-
-    def render_entity_relations(self, entity):
-        # Devices
-        rset = self._cw.execute('Any S WHERE S is Device, '
-                                'S hosted_by X, X eid %(e)s', {'e': entity.eid})
-        if rset:
-            self.w(u'<h3>Devices</h3>')
-            self.wview('list', rset=rset)
-
-
 ############################################################################
 ### DEVICE #################################################################
 ############################################################################
--- a/views/uicfg.py	Mon Jan 20 11:43:33 2014 +0000
+++ b/views/uicfg.py	Mon Jan 20 11:28:09 2014 +0000
@@ -60,3 +60,19 @@
 _pvs.tag_object_of(('Subject', 'related_study', 'Study'), 'relations')
 _pvdc.tag_object_of(('Subject', 'related_study', 'Study'),
                     {'label': _('Measures'), 'vid': 'outofcontext'})
+
+
+###############################################################################
+### CENTER ####################################################################
+###############################################################################
+# XXX : For Center: cannot:
+#       - display indirectly linked entities, viz. Subjects where
+#         Subject -- concerned_by -- Assessment and Center -- holds -- Assessment
+# Name
+_pvs.tag_attribute(('Center', 'name'), 'hidden')
+# Assessment
+_pvs.tag_subject_of(('Center', 'holds', 'Assessment'), 'relations')
+_pvdc.tag_subject_of(('Center', 'holds', 'Assessment'), {'label': _('Assessment'), 'vid': 'list'})
+# Device
+_pvdc.tag_object_of(('Device', 'hosted_by', 'Center'), {'label': _('Devices'), 'vid': 'list'})
+