# HG changeset patch # User cheb # Date 1295514394 -3600 # Node ID ffc982faa264d42fc9babc98310a6b34972b6250 # Parent 824d5b6eae7fd40ec70fadeb8451a4c871b65b27 [views] delete ``permission`` tab in ``SchemaView`` diff -r 824d5b6eae7f -r ffc982faa264 utils.py --- a/utils.py Wed Jan 19 19:15:04 2011 +0100 +++ b/utils.py Thu Jan 20 10:06:34 2011 +0100 @@ -112,7 +112,7 @@ # use networkX instead ? # http://networkx.lanl.gov/reference/algorithms.traversal.html#module-networkx.algorithms.traversal.astar -def transitive_closure_of(entity, relname, _seen=None): +def transitive_closure_of(entity, rtype, _seen=None): """return transitive closure *for the subgraph starting from the given entity* (eg 'parent' entities are not included in the results) """ @@ -120,10 +120,10 @@ _seen = set() _seen.add(entity.eid) yield entity - for child in getattr(entity, relname): + for child in getattr(entity, rtype): if child.eid in _seen: continue - for subchild in transitive_closure_of(child, relname, _seen): + for subchild in transitive_closure_of(child, rtype, _seen): yield subchild diff -r 824d5b6eae7f -r ffc982faa264 web/views/boxes.py --- a/web/views/boxes.py Wed Jan 19 19:15:04 2011 +0100 +++ b/web/views/boxes.py Thu Jan 20 10:06:34 2011 +0100 @@ -208,7 +208,6 @@ raise component.EmptyComponent() self.items = [] - class RsetBox(component.CtxComponent): """helper view class to display an rset in a sidebox""" __select__ = nonempty_rset() & match_kwargs('title', 'vid') diff -r 824d5b6eae7f -r ffc982faa264 web/views/schema.py --- a/web/views/schema.py Wed Jan 19 19:15:04 2011 +0100 +++ b/web/views/schema.py Thu Jan 20 10:06:34 2011 +0100 @@ -145,7 +145,7 @@ __regid__ = 'schema' title = _('instance schema') tabs = [_('schema-diagram'), _('schema-entity-types'), - _('schema-relation-types'), _('schema-security')] + _('schema-relation-types')] default_tab = 'schema-diagram' def call(self): @@ -183,110 +183,6 @@ self.wview('table', self._cw.execute( 'Any X ORDERBY N WHERE X is CWRType, X name N, X final FALSE')) - -class SchemaPermissionsTab(SecurityViewMixIn, StartupView): - __regid__ = 'schema-security' - __select__ = StartupView.__select__ & match_user_groups('managers') - - def call(self, display_relations=True): - skiptypes = skip_types(self._cw) - schema = self._cw.vreg.schema - # compute entities - entities = sorted(eschema for eschema in schema.entities() - if not (eschema.final or eschema in skiptypes)) - # compute relations - if display_relations: - relations = sorted(rschema for rschema in schema.relations() - if not (rschema.final - or rschema in skiptypes - or rschema in META_RTYPES)) - else: - relations = [] - # index - _ = self._cw._ - url = xml_escape(self._cw.build_url('schema')) - self.w(u'
') - self.w(u'

%s

' % _('Index')) - self.w(u'

%s

' % _('Entity types')) - ents = [] - for eschema in sorted(entities): - ents.append(u'%s' % ( - url, eschema.type, eschema.type)) - self.w(u', '.join(ents)) - self.w(u'

%s

' % _('Relation types')) - rels = [] - for rschema in sorted(relations): - rels.append(u'%s' % ( - url , rschema.type, rschema.type)) - self.w(u', '.join(rels)) - # permissions tables - self.display_entities(entities) - if relations: - self.display_relations(relations) - self.w(u'
') - - def has_non_default_perms(self, rdef): - """return true if the given *attribute* relation definition has custom - permission - """ - for action in rdef.ACTIONS: - def_rqlexprs = [] - def_groups = [] - for perm in DEFAULT_ATTRPERMS[action]: - if not isinstance(perm, basestring): - def_rqlexprs.append(perm.expression) - else: - def_groups.append(perm) - rqlexprs = [rql.expression for rql in rdef.get_rqlexprs(action)] - groups = rdef.get_groups(action) - if groups != frozenset(def_groups) or \ - frozenset(rqlexprs) != frozenset(def_rqlexprs): - return True - return False - - def display_entities(self, entities): - _ = self._cw._ - url = xml_escape(self._cw.build_url('schema')) - self.w(u'

%s

' % _('Permissions for entity types')) - for eschema in entities: - self.w(u'

%s (%s) ' % ( - eschema.type, self._cw.build_url('cwetype/%s' % eschema.type), - eschema.type, _(eschema.type))) - self.w(u'%s' % ( - url, self._cw.uiprops['UP_ICON'], _('up'))) - self.w(u'

') - self.w(u'
') - self.permissions_table(eschema) - # display entity attributes only if they have some permissions modified - modified_attrs = [] - for attr, etype in eschema.attribute_definitions(): - rdef = eschema.rdef(attr) - if attr not in META_RTYPES and self.has_non_default_perms(rdef): - modified_attrs.append(rdef) - if modified_attrs: - self.w(u'

%s

' % _('Attributes with non default permissions:')) - self.w(u'
') - self.w(u'
') - for rdef in modified_attrs: - attrtype = str(rdef.rtype) - self.w(u'

%s (%s)

' % (attrtype, _(attrtype))) - self.permissions_table(rdef) - self.w(u'
') - - def display_relations(self, relations): - _ = self._cw._ - url = xml_escape(self._cw.build_url('schema')) - self.w(u'

%s

' % _('Permissions for relations')) - for rschema in relations: - self.w(u'

%s (%s) ' % ( - rschema.type, self._cw.build_url('cwrtype/%s' % rschema.type), - rschema.type, _(rschema.type))) - self.w(u'%s' % ( - url, self._cw.uiprops['UP_ICON'], _('up'))) - self.w(u'

') - self.grouped_permissions_table(rschema) - - # CWEType ###################################################################### # register msgid generated in entity relations tables