[schema view] properly display inheritance (closes #870073).

authorDamien Garaud <damien.garaud@logilab.fr>
changeset076c80543fcd
branchstable
phasepublic
hiddenno
parent revision#a045d3821990 [workflow view]?Display a non-localized version of state/transition names (closes #1912537).
child revision#4b32678c21a7 [schema sync hooks] fix format string
files modified by this revision
web/views/schema.py
# HG changeset patch
# User Damien Garaud <damien.garaud@logilab.fr>
# Date 1328887406 -3600
# Fri Feb 10 16:23:26 2012 +0100
# Branch stable
# Node ID 076c80543fcd0ab7bb24c0720f361e11df3486b2
# Parent a045d3821990496465836e52e7a2215558c34f3c
[schema view] properly display inheritance (closes #870073).

diff --git a/web/views/schema.py b/web/views/schema.py
@@ -202,15 +202,15 @@
1      def render_entity_attributes(self, entity):
2          super(CWETypeDescriptionTab, self).render_entity_attributes(entity)
3          _ = self._cw._
4          # inheritance
5          if entity.specializes:
6 -            self.w(u'<div>%s' % _('Parent class:'))
7 +            self.w(u'<div><strong>%s</strong>' % _('Parent class:'))
8              self.wview('csv', entity.related('specializes', 'subject'))
9              self.w(u'</div>')
10          if entity.reverse_specializes:
11 -            self.w(u'<div>%s' % _('Sub-classes:'))
12 +            self.w(u'<div><strong>%s</strong>' % _('Sub-classes:'))
13              self.wview('csv', entity.related('specializes', 'object'))
14              self.w(u'</div>')
15          # entity schema image
16          self.wview('schemagraph', etype=entity.name)
17          # entity schema attributes
@@ -563,12 +563,18 @@
18                  'fontsize': '10px'
19                  }
20 
21      def edge_properties(self, rschema, subjnode, objnode):
22          """return default DOT drawing options for a relation schema"""
23 +        # Inheritance relation (i.e 'specializes').
24 +        if rschema is None:
25 +            kwargs = {'label': 'Parent class',
26 +                      'color' : 'grey',  'style' : 'filled',
27 +                      'arrowhead': 'empty',
28 +                      'fontsize': '10px'}
29          # symmetric rels are handled differently, let yams decide what's best
30 -        if rschema.symmetric:
31 +        elif rschema.symmetric:
32              kwargs = {'label': rschema.type,
33                        'color': '#887788', 'style': 'dashed',
34                        'dir': 'both', 'arrowhead': 'normal', 'arrowtail': 'normal',
35                        'fontsize': '10px',
36                        'href': self.cw.build_url('cwrtype/%s' % rschema.type)}