web/views/schema.py
changeset 3777 3ef8cdb5fb1c
parent 3720 5376aaadd16b
parent 3768 8c85a2f7f5ad
child 3890 d7a270f50f54
equal deleted inserted replaced
3739:817e96eeac5c 3777:3ef8cdb5fb1c
    16                                 has_related_entities)
    16                                 has_related_entities)
    17 from cubicweb.schema import META_RTYPES, SCHEMA_TYPES, SYSTEM_RTYPES
    17 from cubicweb.schema import META_RTYPES, SCHEMA_TYPES, SYSTEM_RTYPES
    18 from cubicweb.schemaviewer import SchemaViewer
    18 from cubicweb.schemaviewer import SchemaViewer
    19 from cubicweb.view import EntityView, StartupView
    19 from cubicweb.view import EntityView, StartupView
    20 from cubicweb.common import tags, uilib
    20 from cubicweb.common import tags, uilib
    21 from cubicweb.web import action, facet
    21 from cubicweb.web import action, facet, uicfg
    22 from cubicweb.web.views import TmpFileViewMixin
    22 from cubicweb.web.views import TmpFileViewMixin
    23 from cubicweb.web.views import primary, baseviews, tabs, management
    23 from cubicweb.web.views import primary, baseviews, tabs, management
    24 
    24 
    25 ALWAYS_SKIP_TYPES = BASE_TYPES | SCHEMA_TYPES
    25 ALWAYS_SKIP_TYPES = BASE_TYPES | SCHEMA_TYPES
    26 SKIP_TYPES = ALWAYS_SKIP_TYPES | META_RTYPES | SYSTEM_RTYPES
    26 SKIP_TYPES = ALWAYS_SKIP_TYPES | META_RTYPES | SYSTEM_RTYPES
    33 
    33 
    34 def skip_types(req):
    34 def skip_types(req):
    35     if int(req.form.get('skipmeta', True)):
    35     if int(req.form.get('skipmeta', True)):
    36         return SKIP_TYPES
    36         return SKIP_TYPES
    37     return ALWAYS_SKIP_TYPES
    37     return ALWAYS_SKIP_TYPES
       
    38 
       
    39 _pvs = uicfg.primaryview_section
       
    40 for _action in ('read', 'add', 'update', 'delete'):
       
    41     _pvs.tag_subject_of(('*', '%s_permission' % _action, '*'), 'hidden')
       
    42     _pvs.tag_object_of(('*', '%s_permission' % _action, '*'), 'hidden')
    38 
    43 
    39 # global schema view ###########################################################
    44 # global schema view ###########################################################
    40 
    45 
    41 class SchemaView(tabs.TabsMixin, StartupView):
    46 class SchemaView(tabs.TabsMixin, StartupView):
    42     __regid__ = 'schema'
    47     __regid__ = 'schema'
   277     __regid__ = 'cwetype-schema-permissions'
   282     __regid__ = 'cwetype-schema-permissions'
   278     __select__ = EntityView.__select__ & implements('CWEType')
   283     __select__ = EntityView.__select__ & implements('CWEType')
   279 
   284 
   280     def cell_call(self, row, col):
   285     def cell_call(self, row, col):
   281         entity = self.cw_rset.get_entity(row, col)
   286         entity = self.cw_rset.get_entity(row, col)
       
   287         _ = self._cw._
   282         self.w(u'<h2>%s</h2>' % _('Add permissions'))
   288         self.w(u'<h2>%s</h2>' % _('Add permissions'))
   283         rset = self._cw.execute('Any P WHERE X add_permission P, '
   289         rset = self._cw.execute('Any P WHERE X add_permission P, '
   284                                 'X eid %(x)s',
   290                                 'X eid %(x)s',
   285                                 {'x': entity.eid})
   291                                 {'x': entity.eid})
   286         self.wview('outofcontext', rset, 'null')
   292         self.wview('outofcontext', rset, 'null')
   333 
   339 
   334     def render_entity_attributes(self, entity):
   340     def render_entity_attributes(self, entity):
   335         super(CWRTypeSchemaView, self).render_entity_attributes(entity)
   341         super(CWRTypeSchemaView, self).render_entity_attributes(entity)
   336         rschema = self._cw.vreg.schema.rschema(entity.name)
   342         rschema = self._cw.vreg.schema.rschema(entity.name)
   337         viewer = SchemaViewer(self._cw)
   343         viewer = SchemaViewer(self._cw)
   338         layout = viewer.visit_relationschema(rschema)
   344         layout = viewer.visit_relationschema(rschema, title=False)
   339         self.w(uilib.ureport_as_html(layout))
   345         self.w(uilib.ureport_as_html(layout))
   340         if not rschema.final:
   346         if not rschema.final:
   341             msg = self._cw._('graphical schema for %s') % entity.name
   347             msg = self._cw._('graphical schema for %s') % entity.name
   342             self.w(tags.img(src=entity.absolute_url(vid='schemagraph'),
   348             self.w(tags.img(src=entity.absolute_url(vid='schemagraph'),
   343                             alt=msg))
   349                             alt=msg))