web/views/startup.py
changeset 2436 44b2eea35efa
parent 2387 ea1defea9636
child 2476 1294a6bdf3bf
--- a/web/views/startup.py	Thu Jul 23 13:35:06 2009 +0200
+++ b/web/views/startup.py	Thu Jul 23 15:07:08 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))
-
-