[views] Discard Scan primary view. Provide uicfg Brainomics primary view customization instead (related to #3340591)
authorVladimir Popescu <vladimir.popescu@logilab.fr>
Tue, 17 Dec 2013 11:13:36 +0100
changeset 645 f4014875a284
parent 644 66e70b99068c
child 646 ee961cbb4c07
[views] Discard Scan primary view. Provide uicfg Brainomics primary view customization instead (related to #3340591)
views/primary.py
views/uicfg.py
--- a/views/primary.py	Mon Dec 16 18:54:56 2013 +0100
+++ b/views/primary.py	Tue Dec 17 11:13:36 2013 +0100
@@ -101,65 +101,6 @@
                 tab.render(self.w)
         w(u'</div>')
 
-
-###############################################################################
-### SCAN ######################################################################
-###############################################################################
-class ScanPrimaryView(BrainomicsPrimaryView):
-    __select__ = BrainomicsPrimaryView.__select__ & is_instance('Scan')
-
-    def render_entity_attributes(self, entity):
-        subject = entity.concerns[0]
-        subject = u'<a href="%s">%s</a>' % (subject.absolute_url(), subject.dc_title())
-        device = entity.uses_device
-        if entity.uses_device:
-            device = u'<a href="%s">%s</a>' % (device[0].absolute_url(), device[0].dc_title())
-        else:
-            device = None
-        assessment = entity.reverse_generates[0]
-        assessment = u'<a href="%s">%s</a>' % (assessment.absolute_url(), assessment.dc_title())
-        return [(self._cw._('Identifier'), entity.identifier),
-                (self._cw._('Label'), entity.label),
-                (self._cw._('Type'), entity.type),
-                (self._cw._('Format'), entity.format),
-                (self._cw._('Position in acquisition'), entity.position_acquisition),
-                (self._cw._('Subject'), subject),
-                (self._cw._('Device'), device),
-                (self._cw._('Assessment'), assessment),
-               ]
-
-    def display_header(self, entity):
-        w = self.w
-        w(u'<div class="well">')
-        w(u'<div class="page-header">')
-        w(u'<h2>%s</h2>' % xml_escape(entity.dc_title()))
-        w(u'</div>')
-        w(u'<dl class="dl-horizontal">')
-        for label, value in self.render_entity_attributes(entity):
-            if value:
-                self.render_entity_attribute(self._cw._(lavel), value)
-        # Add data info
-        data = entity.has_data
-        if data:
-            data[0].view('scan-data-view', w=w)
-        w(u'</dl>')
-        # Additional header
-        self.display_additional_header(entity)
-        # Data
-        self.display_data_table(entity)
-        w(u'</div>')
-
-    def render_entity_relations(self, entity):
-        # Results file
-        self.w(entity.view('results-view'))
-        # Related external resources
-        rset = self._cw.execute('(Any E WHERE X external_resources E, X eid %(e)s) '
-                                'UNION (Any E WHERE A generates X, A external_resources E, X eid %(e)s)',
-                                {'e': entity.eid})
-        if rset:
-            self.w(u'<h3>%s</h3>' % self._cw._('External Resources'))
-            self.wview('list', rset=rset)
-
 ###############################################################################
 ### REGISTRATION CALLBACK #####################################################
 ###############################################################################
--- a/views/uicfg.py	Mon Dec 16 18:54:56 2013 +0100
+++ b/views/uicfg.py	Tue Dec 17 11:13:36 2013 +0100
@@ -270,3 +270,15 @@
 # Answers
 _pvs.tag_object_of(('*', 'question', 'Question'), 'relations')
 _pvdc.tag_object_of(('*', 'question', 'Question'), {'vid': 'table'})
+
+
+###############################################################################
+### SCAN ######################################################################
+###############################################################################
+_pvs.tag_subject_of(('Scan', 'concerns', '*'), 'attributes')
+_pvs.tag_subject_of(('Scan', 'uses_device', '*'), 'attributes')
+_pvs.tag_object_of(('*', 'generates', 'Scan'), 'attributes')
+_pvs.tag_subject_of(('Scan', 'has_data', '*'), 'relations')
+_pvdc.tag_subject_of(('Scan', 'has_data', '*'),
+                     {'vid': 'scan-data-view', 'label': _(' ')})
+_pvs.tag_object_of(('*', 'external_resources', 'ExternalResource'), 'relations')