--- a/server/test/unittest_schemaserial.py Thu Jul 23 15:16:43 2009 +0200
+++ b/server/test/unittest_schemaserial.py Thu Jul 23 15:16:49 2009 +0200
@@ -23,15 +23,15 @@
def test_eschema2rql1(self):
self.assertListEquals(list(eschema2rql(schema.eschema('CWAttribute'))),
[
- ('INSERT CWEType X: X description %(description)s,X final %(final)s,X meta %(meta)s,X name %(name)s',
+ ('INSERT CWEType X: X description %(description)s,X final %(final)s,X name %(name)s',
{'description': u'define a final relation: link a final relation type from a non final entity to a final entity type. used to build the application schema',
- 'meta': True, 'name': u'CWAttribute', 'final': False})
+ 'name': u'CWAttribute', 'final': False})
])
def test_eschema2rql2(self):
self.assertListEquals(list(eschema2rql(schema.eschema('String'))), [
- ('INSERT CWEType X: X description %(description)s,X final %(final)s,X meta %(meta)s,X name %(name)s',
- {'description': u'', 'final': True, 'meta': True, 'name': u'String'})])
+ ('INSERT CWEType X: X description %(description)s,X final %(final)s,X name %(name)s',
+ {'description': u'', 'final': True, 'name': u'String'})])
def test_eschema2rql_specialization(self):
self.assertListEquals(list(specialize2rql(schema)),
@@ -44,8 +44,8 @@
def test_rschema2rql1(self):
self.assertListEquals(list(rschema2rql(schema.rschema('relation_type'))),
[
- ('INSERT CWRType X: X description %(description)s,X final %(final)s,X fulltext_container %(fulltext_container)s,X inlined %(inlined)s,X meta %(meta)s,X name %(name)s,X symetric %(symetric)s',
- {'description': u'link a relation definition to its relation type', 'meta': True, 'symetric': False, 'name': u'relation_type', 'final' : False, 'fulltext_container': None, 'inlined': True}),
+ ('INSERT CWRType X: X description %(description)s,X final %(final)s,X fulltext_container %(fulltext_container)s,X inlined %(inlined)s,X name %(name)s,X symetric %(symetric)s',
+ {'description': u'link a relation definition to its relation type', 'symetric': False, 'name': u'relation_type', 'final' : False, 'fulltext_container': None, 'inlined': True}),
('INSERT CWRelation X: X cardinality %(cardinality)s,X composite %(composite)s,X description %(description)s,X ordernum %(ordernum)s,X relation_type ER,X from_entity SE,X to_entity OE WHERE SE name %(se)s,ER name %(rt)s,OE name %(oe)s',
{'rt': 'relation_type', 'description': u'', 'composite': u'object', 'oe': 'CWRType',
@@ -63,7 +63,7 @@
def test_rschema2rql2(self):
self.assertListEquals(list(rschema2rql(schema.rschema('add_permission'))),
[
- ('INSERT CWRType X: X description %(description)s,X final %(final)s,X fulltext_container %(fulltext_container)s,X inlined %(inlined)s,X meta %(meta)s,X name %(name)s,X symetric %(symetric)s', {'description': u'core relation giving to a group the permission to add an entity or relation type', 'meta': True, 'symetric': False, 'name': u'add_permission', 'final': False, 'fulltext_container': None, 'inlined': False}),
+ ('INSERT CWRType X: X description %(description)s,X final %(final)s,X fulltext_container %(fulltext_container)s,X inlined %(inlined)s,X name %(name)s,X symetric %(symetric)s', {'description': u'core relation giving to a group the permission to add an entity or relation type', 'symetric': False, 'name': u'add_permission', 'final': False, 'fulltext_container': None, 'inlined': False}),
('INSERT CWRelation X: X cardinality %(cardinality)s,X composite %(composite)s,X description %(description)s,X ordernum %(ordernum)s,X relation_type ER,X from_entity SE,X to_entity OE WHERE SE name %(se)s,ER name %(rt)s,OE name %(oe)s',
{'rt': 'add_permission', 'description': u'groups allowed to add entities/relations of this type', 'composite': None, 'oe': 'CWGroup', 'ordernum': 3, 'cardinality': u'**', 'se': 'CWEType'}),
@@ -79,8 +79,8 @@
def test_rschema2rql3(self):
self.assertListEquals(list(rschema2rql(schema.rschema('cardinality'))),
[
- ('INSERT CWRType X: X description %(description)s,X final %(final)s,X fulltext_container %(fulltext_container)s,X inlined %(inlined)s,X meta %(meta)s,X name %(name)s,X symetric %(symetric)s',
- {'description': u'', 'meta': False, 'symetric': False, 'name': u'cardinality', 'final': True, 'fulltext_container': None, 'inlined': False}),
+ ('INSERT CWRType X: X description %(description)s,X final %(final)s,X fulltext_container %(fulltext_container)s,X inlined %(inlined)s,X name %(name)s,X symetric %(symetric)s',
+ {'description': u'', 'symetric': False, 'name': u'cardinality', 'final': True, 'fulltext_container': None, 'inlined': False}),
('INSERT CWAttribute X: X cardinality %(cardinality)s,X defaultval %(defaultval)s,X description %(description)s,X fulltextindexed %(fulltextindexed)s,X indexed %(indexed)s,X internationalizable %(internationalizable)s,X ordernum %(ordernum)s,X relation_type ER,X from_entity SE,X to_entity OE WHERE SE name %(se)s,ER name %(rt)s,OE name %(oe)s',
{'rt': 'cardinality', 'description': u'subject/object cardinality', 'internationalizable': True, 'fulltextindexed': False, 'ordernum': 5, 'defaultval': None, 'indexed': False, 'cardinality': u'?1', 'oe': 'String', 'se': 'CWRelation'}),
@@ -100,31 +100,31 @@
def test_updateeschema2rql1(self):
self.assertListEquals(list(updateeschema2rql(schema.eschema('CWAttribute'))),
- [('SET X description %(description)s,X final %(final)s,X meta %(meta)s,X name %(name)s WHERE X is CWEType, X name %(et)s',
- {'description': u'define a final relation: link a final relation type from a non final entity to a final entity type. used to build the application schema', 'meta': True, 'et': 'CWAttribute', 'final': False, 'name': u'CWAttribute'}),
+ [('SET X description %(description)s,X final %(final)s,X name %(name)s WHERE X is CWEType, X name %(et)s',
+ {'description': u'define a final relation: link a final relation type from a non final entity to a final entity type. used to build the application schema', 'et': 'CWAttribute', 'final': False, 'name': u'CWAttribute'}),
])
def test_updateeschema2rql2(self):
self.assertListEquals(list(updateeschema2rql(schema.eschema('String'))),
- [('SET X description %(description)s,X final %(final)s,X meta %(meta)s,X name %(name)s WHERE X is CWEType, X name %(et)s',
- {'description': u'', 'meta': True, 'et': 'String', 'final': True, 'name': u'String'})
+ [('SET X description %(description)s,X final %(final)s,X name %(name)s WHERE X is CWEType, X name %(et)s',
+ {'description': u'', 'et': 'String', 'final': True, 'name': u'String'})
])
def test_updaterschema2rql1(self):
self.assertListEquals(list(updaterschema2rql(schema.rschema('relation_type'))),
[
- ('SET X description %(description)s,X final %(final)s,X fulltext_container %(fulltext_container)s,X inlined %(inlined)s,X meta %(meta)s,X name %(name)s,X symetric %(symetric)s WHERE X is CWRType, X name %(rt)s',
+ ('SET X description %(description)s,X final %(final)s,X fulltext_container %(fulltext_container)s,X inlined %(inlined)s,X name %(name)s,X symetric %(symetric)s WHERE X is CWRType, X name %(rt)s',
{'rt': 'relation_type', 'symetric': False,
'description': u'link a relation definition to its relation type',
- 'meta': True, 'final': False, 'fulltext_container': None, 'inlined': True, 'name': u'relation_type'})
+ 'final': False, 'fulltext_container': None, 'inlined': True, 'name': u'relation_type'})
])
def test_updaterschema2rql2(self):
expected = [
- ('SET X description %(description)s,X final %(final)s,X fulltext_container %(fulltext_container)s,X inlined %(inlined)s,X meta %(meta)s,X name %(name)s,X symetric %(symetric)s WHERE X is CWRType, X name %(rt)s',
+ ('SET X description %(description)s,X final %(final)s,X fulltext_container %(fulltext_container)s,X inlined %(inlined)s,X name %(name)s,X symetric %(symetric)s WHERE X is CWRType, X name %(rt)s',
{'rt': 'add_permission', 'symetric': False,
'description': u'core relation giving to a group the permission to add an entity or relation type',
- 'meta': True, 'final': False, 'fulltext_container': None, 'inlined': False, 'name': u'add_permission'})
+ 'final': False, 'fulltext_container': None, 'inlined': False, 'name': u'add_permission'})
]
for i, (rql, args) in enumerate(updaterschema2rql(schema.rschema('add_permission'))):
yield self.assertEquals, (rql, args), expected[i]
--- a/web/views/schema.py Thu Jul 23 15:16:43 2009 +0200
+++ b/web/views/schema.py Thu Jul 23 15:16:49 2009 +0200
@@ -10,37 +10,178 @@
from itertools import cycle
from logilab.mtconverter import xml_escape
-from yams import schema2dot as s2d
+from yams import BASE_TYPES, schema2dot as s2d
-from cubicweb.selectors import implements, yes
+from cubicweb.selectors import implements, yes, match_user_groups
from cubicweb.schema import META_RELATIONS_TYPES, SCHEMA_TYPES
from cubicweb.schemaviewer import SchemaViewer
from cubicweb.view import EntityView, StartupView
from cubicweb.common import tags, uilib
-from cubicweb.web import action
-from cubicweb.web.views import TmpFileViewMixin, primary, baseviews, tabs
-from cubicweb.web.facet import AttributeFacet
+from cubicweb.web import action, facet
+from cubicweb.web.views import TmpFileViewMixin
+from cubicweb.web.views import primary, baseviews, tabs, management
-SKIP_TYPES = set()
-SKIP_TYPES.update(META_RELATIONS_TYPES)
-SKIP_TYPES.update(SCHEMA_TYPES)
+ALWAYS_SKIP_TYPES = BASE_TYPES | SCHEMA_TYPES
+SKIP_TYPES = ALWAYS_SKIP_TYPES | META_RELATIONS_TYPES
+SKIP_TYPES.update(set(('Transition', 'State', 'TrInfo',
+ 'CWUser', 'CWGroup',
+ 'CWCache', 'CWProperty', 'CWPermission',
+ 'ExternalUri')))
def skip_types(req):
if int(req.form.get('skipmeta', True)):
return SKIP_TYPES
- return ()
+ return ALWAYS_SKIP_TYPES
+
+# global schema view ###########################################################
+
+class SchemaView(tabs.TabsMixin, StartupView):
+ id = 'schema'
+ title = _('application schema')
+ tabs = [_('schema-text'), _('schema-image')]
+ default_tab = 'schema-text'
+
+ def call(self):
+ """display schema information"""
+ self.req.add_js('cubicweb.ajax.js')
+ self.req.add_css(('cubicweb.schema.css','cubicweb.acl.css'))
+ self.w(u'<h1>%s</h1>' % _('Schema of the data model'))
+ self.render_tabs(self.tabs, self.default_tab)
+
+
+class SchemaTabImageView(StartupView):
+ id = 'schema-image'
-class ViewSchemaAction(action.Action):
- id = 'schema'
- __select__ = yes()
+ def call(self):
+ self.w(_(u'<div>This schema of the data model <em>excludes</em> the '
+ u'meta-data, but you can also display a <a href="%s">complete '
+ u'schema with meta-data</a>.</div>')
+ % xml_escape(self.build_url('view', vid='schemagraph', skipmeta=0)))
+ self.w(u'<img src="%s" alt="%s"/>\n' % (
+ xml_escape(self.req.build_url('view', vid='schemagraph', skipmeta=1)),
+ self.req._("graphical representation of the application'schema")))
+
+
+class SchemaTabTextView(StartupView):
+ id = 'schema-text'
+
+ def call(self):
+ rset = self.req.execute('Any X ORDERBY N WHERE X is CWEType, X name N, '
+ 'X final FALSE')
+ self.wview('table', rset, displayfilter=True)
+
+
+class ManagerSchemaPermissionsView(StartupView, management.SecurityViewMixIn):
+ id = 'schema-security'
+ __select__ = StartupView.__select__ & match_user_groups('managers')
- title = _("site schema")
- category = 'siteactions'
- order = 30
+ def call(self, display_relations=True):
+ self.req.add_css('cubicweb.acl.css')
+ skiptypes = skip_types(self.req)
+ formparams = {}
+ formparams['sec'] = self.id
+ if not skiptypes:
+ formparams['skipmeta'] = u'0'
+ schema = self.schema
+ # compute entities
+ entities = sorted(eschema for eschema in schema.entities()
+ if not (eschema.is_final() or eschema in skiptypes))
+ # compute relations
+ if display_relations:
+ relations = sorted(rschema for rschema in schema.relations()
+ if not (rschema.is_final()
+ or rschema in skiptypes
+ or rschema in META_RELATIONS_TYPES))
+ else:
+ relations = []
+ # index
+ _ = self.req._
+ self.w(u'<div id="schema_security"><a id="index" href="index"/>')
+ self.w(u'<h2 class="schema">%s</h2>' % _('index').capitalize())
+ self.w(u'<h4>%s</h4>' % _('Entities').capitalize())
+ ents = []
+ for eschema in sorted(entities):
+ url = xml_escape(self.build_url('schema', **formparams))
+ ents.append(u'<a class="grey" href="%s#%s">%s</a> (%s)' % (
+ url, eschema.type, eschema.type, _(eschema.type)))
+ self.w(u', '.join(ents))
+ self.w(u'<h4>%s</h4>' % (_('relations').capitalize()))
+ rels = []
+ for rschema in sorted(relations):
+ url = xml_escape(self.build_url('schema', **formparams))
+ rels.append(u'<a class="grey" href="%s#%s">%s</a> (%s), ' % (
+ url , rschema.type, rschema.type, _(rschema.type)))
+ self.w(u', '.join(ents))
+ # entities
+ self.display_entities(entities, formparams)
+ # relations
+ if relations:
+ self.display_relations(relations, formparams)
+ self.w(u'</div>')
- def url(self):
- return self.build_url(self.id)
+ def display_entities(self, entities, formparams):
+ _ = self.req._
+ self.w(u'<a id="entities" href="entities"/>')
+ self.w(u'<h2 class="schema">%s</h2>' % _('permissions for entities').capitalize())
+ for eschema in entities:
+ self.w(u'<a id="%s" href="%s"/>' % (eschema.type, eschema.type))
+ self.w(u'<h3 class="schema">%s (%s) ' % (eschema.type, _(eschema.type)))
+ url = xml_escape(self.build_url('schema', **formparams) + '#index')
+ self.w(u'<a href="%s"><img src="%s" alt="%s"/></a>' % (
+ url, self.req.external_resource('UP_ICON'), _('up')))
+ self.w(u'</h3>')
+ self.w(u'<div style="margin: 0px 1.5em">')
+ self.schema_definition(eschema, link=False)
+ # display entity attributes only if they have some permissions modified
+ modified_attrs = []
+ for attr, etype in eschema.attribute_definitions():
+ if self.has_schema_modified_permissions(attr, attr.ACTIONS):
+ modified_attrs.append(attr)
+ if modified_attrs:
+ self.w(u'<h4>%s</h4>' % _('attributes with modified permissions:').capitalize())
+ self.w(u'</div>')
+ self.w(u'<div style="margin: 0px 6em">')
+ for attr in modified_attrs:
+ self.w(u'<h4 class="schema">%s (%s)</h4> ' % (attr.type, _(attr.type)))
+ self.schema_definition(attr, link=False)
+ self.w(u'</div>')
+ def display_relations(self, relations, formparams):
+ _ = self.req._
+ self.w(u'<a id="relations" href="relations"/>')
+ self.w(u'<h2 class="schema">%s </h2>' % _('permissions for relations').capitalize())
+ for rschema in relations:
+ self.w(u'<a id="%s" href="%s"/>' % (rschema.type, rschema.type))
+ self.w(u'<h3 class="schema">%s (%s) ' % (rschema.type, _(rschema.type)))
+ url = xml_escape(self.build_url('schema', **formparams) + '#index')
+ self.w(u'<a href="%s"><img src="%s" alt="%s"/></a>' % (
+ url, self.req.external_resource('UP_ICON'), _('up')))
+ self.w(u'</h3>')
+ self.w(u'<div style="margin: 0px 1.5em">')
+ subjects = [str(subj) for subj in rschema.subjects()]
+ self.w(u'<div><strong>%s</strong> %s (%s)</div>' % (
+ _('subject_plural:'),
+ ', '.join(str(subj) for subj in rschema.subjects()),
+ ', '.join(_(str(subj)) for subj in rschema.subjects())))
+ self.w(u'<div><strong>%s</strong> %s (%s)</div>' % (
+ _('object_plural:'),
+ ', '.join(str(obj) for obj in rschema.objects()),
+ ', '.join(_(str(obj)) for obj in rschema.objects())))
+ self.schema_definition(rschema, link=False)
+ self.w(u'</div>')
+
+
+class SchemaUreportsView(StartupView):
+ id = 'schema-block'
+
+ def call(self):
+ viewer = SchemaViewer(self.req)
+ layout = viewer.visit_schema(self.schema, display_relations=True,
+ skiptypes=skip_types(self.req))
+ self.w(uilib.ureport_as_html(layout))
+
+
+# CWAttribute / CWRelation #####################################################
class CWRDEFPrimaryView(primary.PrimaryView):
__select__ = implements('CWAttribute', 'CWRelation')
@@ -196,11 +337,13 @@
def should_display_schema(self, rschema):
return (super(RestrictedSchemaVisitorMixIn, self).should_display_schema(rschema)
- and rschema.has_local_role('read') or rschema.has_perm(self.req, 'read'))
+ and (rschema.has_local_role('read')
+ or rschema.has_perm(self.req, 'read')))
def should_display_attr(self, rschema):
return (super(RestrictedSchemaVisitorMixIn, self).should_display_attr(rschema)
- and rschema.has_local_role('read') or rschema.has_perm(self.req, 'read'))
+ and (rschema.has_local_role('read')
+ or rschema.has_perm(self.req, 'read')))
class FullSchemaVisitor(RestrictedSchemaVisitorMixIn, s2d.FullSchemaVisitor):
@@ -221,10 +364,12 @@
def _generate(self, tmpfile):
"""display global schema information"""
+ print 'skipedtypes', skip_types(self.req)
visitor = FullSchemaVisitor(self.req, self.schema,
skiptypes=skip_types(self.req))
s2d.schema2dot(outputfile=tmpfile, visitor=visitor)
+
class CWETypeSchemaImageView(TmpFileViewMixin, EntityView):
id = 'schemagraph'
__select__ = implements('CWEType')
@@ -238,6 +383,7 @@
skiptypes=skip_types(self.req))
s2d.schema2dot(outputfile=tmpfile, visitor=visitor)
+
class CWRTypeSchemaImageView(CWETypeSchemaImageView):
__select__ = implements('CWRType')
@@ -248,9 +394,21 @@
visitor = OneHopRSchemaVisitor(self.req, rschema)
s2d.schema2dot(outputfile=tmpfile, visitor=visitor)
-### facets
+
+# misc: facets, actions ########################################################
+
+class CWFinalFacet(facet.AttributeFacet):
+ id = 'cwfinal-facet'
+ __select__ = facet.AttributeFacet.__select__ & implements('CWEType', 'CWRType')
+ rtype = 'final'
-class CWFinalFacet(AttributeFacet):
- id = 'cwfinal-facet'
- __select__ = AttributeFacet.__select__ & implements('CWEType', 'CWRType')
- rtype = 'final'
+class ViewSchemaAction(action.Action):
+ id = 'schema'
+ __select__ = yes()
+
+ title = _("site schema")
+ category = 'siteactions'
+ order = 30
+
+ def url(self):
+ return self.build_url(self.id)
--- a/web/views/startup.py Thu Jul 23 15:16:43 2009 +0200
+++ b/web/views/startup.py Thu Jul 23 15:16:49 2009 +0200
@@ -14,10 +14,8 @@
from cubicweb.view import StartupView
from cubicweb.selectors import match_user_groups, implements
-from cubicweb.schema import META_RELATIONS_TYPES, display_name
-from cubicweb.common.uilib import ureport_as_html
+from cubicweb.schema import display_name
from cubicweb.web import ajax_replace_url, uicfg, httpcache
-from cubicweb.web.views import tabs, management, schema as schemamod
class ManageView(StartupView):
id = 'manage'
@@ -163,154 +161,3 @@
def display_folders(self):
return 'Folder' in self.schema and self.req.execute('Any COUNT(X) WHERE X is Folder')[0][0]
-class SchemaView(tabs.TabsMixin, StartupView):
- id = 'schema'
- title = _('application schema')
- tabs = [_('schema-text'), _('schema-image')]
- default_tab = 'schema-text'
-
- def call(self):
- """display schema information"""
- self.req.add_js('cubicweb.ajax.js')
- self.req.add_css(('cubicweb.schema.css','cubicweb.acl.css'))
- self.w(u'<h1>%s</h1>' % _('Schema of the data model'))
- self.render_tabs(self.tabs, self.default_tab)
-
-
-class SchemaTabImageView(StartupView):
- id = 'schema-image'
-
- def call(self):
- self.w(_(u'<div>This schema of the data model <em>excludes</em> the '
- u'meta-data, but you can also display a <a href="%s">complete '
- u'schema with meta-data</a>.</div>')
- % xml_escape(self.build_url('view', vid='schemagraph', withmeta=1)))
- self.w(u'<img src="%s" alt="%s"/>\n' % (
- xml_escape(self.req.build_url('view', vid='schemagraph', skipmeta=1)),
- self.req._("graphical representation of the application'schema")))
-
-
-class SchemaTabTextView(StartupView):
- id = 'schema-text'
-
- def call(self):
- rset = self.req.execute('Any X ORDERBY N WHERE X is CWEType, X name N, '
- 'X final FALSE')
- self.wview('table', rset, displayfilter=True)
-
-
-class ManagerSchemaPermissionsView(StartupView, management.SecurityViewMixIn):
- id = 'schema-security'
- __select__ = StartupView.__select__ & match_user_groups('managers')
-
- def call(self, display_relations=True):
- self.req.add_css('cubicweb.acl.css')
- skiptypes = schemamod.skip_types(self.req)
- formparams = {}
- formparams['sec'] = self.id
- if not skiptypes:
- formparams['skipmeta'] = u'0'
- schema = self.schema
- # compute entities
- entities = sorted(eschema for eschema in schema.entities()
- if not (eschema.is_final() or eschema in skiptypes))
- # compute relations
- if display_relations:
- relations = sorted(rschema for rschema in schema.relations()
- if not (rschema.is_final()
- or rschema in skiptypes
- or rschema in META_RELATIONS_TYPES))
- else:
- relations = []
- # index
- _ = self.req._
- self.w(u'<div id="schema_security"><a id="index" href="index"/>')
- self.w(u'<h2 class="schema">%s</h2>' % _('index').capitalize())
- self.w(u'<h4>%s</h4>' % _('Entities').capitalize())
- ents = []
- for eschema in sorted(entities):
- url = xml_escape(self.build_url('schema', **formparams))
- ents.append(u'<a class="grey" href="%s#%s">%s</a> (%s)' % (
- url, eschema.type, eschema.type, _(eschema.type)))
- self.w(u', '.join(ents))
- self.w(u'<h4>%s</h4>' % (_('relations').capitalize()))
- rels = []
- for rschema in sorted(relations):
- url = xml_escape(self.build_url('schema', **formparams))
- rels.append(u'<a class="grey" href="%s#%s">%s</a> (%s), ' % (
- url , rschema.type, rschema.type, _(rschema.type)))
- self.w(u', '.join(ents))
- # entities
- self.display_entities(entities, formparams)
- # relations
- if relations:
- self.display_relations(relations, formparams)
- self.w(u'</div>')
-
- def display_entities(self, entities, formparams):
- _ = self.req._
- self.w(u'<a id="entities" href="entities"/>')
- self.w(u'<h2 class="schema">%s</h2>' % _('permissions for entities').capitalize())
- for eschema in entities:
- self.w(u'<a id="%s" href="%s"/>' % (eschema.type, eschema.type))
- self.w(u'<h3 class="schema">%s (%s) ' % (eschema.type, _(eschema.type)))
- url = xml_escape(self.build_url('schema', **formparams) + '#index')
- self.w(u'<a href="%s"><img src="%s" alt="%s"/></a>' % (
- url, self.req.external_resource('UP_ICON'), _('up')))
- self.w(u'</h3>')
- self.w(u'<div style="margin: 0px 1.5em">')
- self.schema_definition(eschema, link=False)
- # display entity attributes only if they have some permissions modified
- modified_attrs = []
- for attr, etype in eschema.attribute_definitions():
- if self.has_schema_modified_permissions(attr, attr.ACTIONS):
- modified_attrs.append(attr)
- if modified_attrs:
- self.w(u'<h4>%s</h4>' % _('attributes with modified permissions:').capitalize())
- self.w(u'</div>')
- self.w(u'<div style="margin: 0px 6em">')
- for attr in modified_attrs:
- self.w(u'<h4 class="schema">%s (%s)</h4> ' % (attr.type, _(attr.type)))
- self.schema_definition(attr, link=False)
- self.w(u'</div>')
-
- def display_relations(self, relations, formparams):
- _ = self.req._
- self.w(u'<a id="relations" href="relations"/>')
- self.w(u'<h2 class="schema">%s </h2>' % _('permissions for relations').capitalize())
- for rschema in relations:
- self.w(u'<a id="%s" href="%s"/>' % (rschema.type, rschema.type))
- self.w(u'<h3 class="schema">%s (%s) ' % (rschema.type, _(rschema.type)))
- url = xml_escape(self.build_url('schema', **formparams) + '#index')
- self.w(u'<a href="%s"><img src="%s" alt="%s"/></a>' % (
- url, self.req.external_resource('UP_ICON'), _('up')))
- self.w(u'</h3>')
- self.w(u'<div style="margin: 0px 1.5em">')
- subjects = [str(subj) for subj in rschema.subjects()]
- self.w(u'<div><strong>%s</strong> %s (%s)</div>' % (
- _('subject_plural:'),
- ', '.join(str(subj) for subj in rschema.subjects()),
- ', '.join(_(str(subj)) for subj in rschema.subjects())))
- self.w(u'<div><strong>%s</strong> %s (%s)</div>' % (
- _('object_plural:'),
- ', '.join(str(obj) for obj in rschema.objects()),
- ', '.join(_(str(obj)) for obj in rschema.objects())))
- self.schema_definition(rschema, link=False)
- self.w(u'</div>')
-
-
-class SchemaUreportsView(StartupView):
- id = 'schematext'
-
- def call(self):
- from cubicweb.schemaviewer import SchemaViewer
- if int(self.req.form.get('skipmeta', True)):
- skip = schema.SKIP_TYPES
- else:
- skip = ()
- viewer = SchemaViewer(self.req)
- layout = viewer.visit_schema(self.schema, display_relations=True,
- skiptypes=skip)
- self.w(ureport_as_html(layout))
-
-