[views] Discard Device primary view. Provide uicfg Brainomics primary view customization instead (related to #3340591)
authorVladimir Popescu <vladimir.popescu@logilab.fr>
Mon, 20 Jan 2014 11:45:13 +0000
changeset 630 47911e3b35bc
parent 629 7ec6d3ca59b8
child 631 06368232fa3e
[views] Discard Device 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:28:09 2014 +0000
+++ b/views/primary.py	Mon Jan 20 11:45:13 2014 +0000
@@ -122,26 +122,6 @@
         if rset:
             self.wview('list', rset)
 
-############################################################################
-### DEVICE #################################################################
-############################################################################
-class DevicePrimaryView(BrainomicsPrimaryView):
-    __select__ = BrainomicsPrimaryView.__select__ & is_instance('Device')
-
-    def render_entity_attributes(self, entity):
-        center = entity.hosted_by[0]
-        center = u'<a href="%s">%s</a>' % (center.absolute_url(), center.dc_title())
-        return [(self._cw._('Name'), entity.name),
-                (self._cw._('Manufacturer'), entity.manufacturer),
-                (self._cw._('Model'), entity.model),
-                (self._cw._('Hosted by'), center),]
-
-    def iterate_data(self, entity):
-        data = []
-        rql = 'DISTINCT Any S WHERE S uses_device X, X eid %s' % entity.eid
-        data = self._build_data(data, rql, self._cw._('Generated measures'))
-        return data
-
 
 ############################################################################
 ### ASSESSMENT #############################################################
--- a/views/uicfg.py	Mon Jan 20 11:28:09 2014 +0000
+++ b/views/uicfg.py	Mon Jan 20 11:45:13 2014 +0000
@@ -76,3 +76,16 @@
 # Device
 _pvdc.tag_object_of(('Device', 'hosted_by', 'Center'), {'label': _('Devices'), 'vid': 'list'})
 
+
+###############################################################################
+### DEVICE ####################################################################
+###############################################################################
+# XXX : for Device: cannot:
+#       - enable the DISTINCT on the generated measures which use the device
+# Name
+_pvs.tag_attribute(('Device', 'name'), 'hidden')
+# Center
+_pvs.tag_subject_of(('Device', 'hosted_by', 'Center'), 'attributes')
+# Measures
+_pvdc.tag_object_of(('*', 'uses_device', 'Device'),
+                    {'label': _('Generated measures'), 'vid': 'outofcontext'})