29 def format_acls(self, schema, access_types): |
29 def format_acls(self, schema, access_types): |
30 """return a layout displaying access control lists""" |
30 """return a layout displaying access control lists""" |
31 data = [self.req._('access type'), self.req._('groups')] |
31 data = [self.req._('access type'), self.req._('groups')] |
32 for access_type in access_types: |
32 for access_type in access_types: |
33 data.append(self.req._(access_type)) |
33 data.append(self.req._(access_type)) |
34 acls = [self.req._(group) for group in schema.get_groups(access_type)] |
34 acls = [Link(self.req.build_url('cwgroup/%s' % group), self.req._(group)) |
35 acls += (rqlexp.expression for rqlexp in schema.get_rqlexprs(access_type)) |
35 for group in schema.get_groups(access_type)] |
36 data.append(', '.join(acls)) |
36 acls += (Text(rqlexp.expression) for rqlexp in schema.get_rqlexprs(access_type)) |
|
37 acls = [n for _n in acls for n in (_n, Text(', '))][:-1] |
|
38 data.append(Span(children=acls)) |
37 return Section(children=(Table(cols=2, cheaders=1, rheaders=1, children=data),), |
39 return Section(children=(Table(cols=2, cheaders=1, rheaders=1, children=data),), |
38 klass='acl') |
40 klass='acl') |
39 |
41 |
40 |
42 |
41 def visit_schema(self, schema, display_relations=0, skiptypes=()): |
43 def visit_schema(self, schema, display_relations=0, skiptypes=()): |
105 etype = eschema.type |
107 etype = eschema.type |
106 layout = Section(children=' ', klass='clear') |
108 layout = Section(children=' ', klass='clear') |
107 layout.append(Link(etype,' ' , id=etype)) # anchor |
109 layout.append(Link(etype,' ' , id=etype)) # anchor |
108 title = Link(self.eschema_link_url(eschema), etype) |
110 title = Link(self.eschema_link_url(eschema), etype) |
109 boxchild = [Section(children=(title, ' (%s)'% eschema.display_name(self.req)), klass='title')] |
111 boxchild = [Section(children=(title, ' (%s)'% eschema.display_name(self.req)), klass='title')] |
110 table = Table(cols=4, rheaders=1, |
112 table = Table(cols=4, rheaders=1, klass='listing', |
111 children=self._entity_attributes_data(eschema)) |
113 children=self._entity_attributes_data(eschema)) |
112 boxchild.append(Section(children=(table,), klass='body')) |
114 boxchild.append(Section(children=(table,), klass='body')) |
113 data = [] |
115 data = [] |
114 data.append(Section(children=boxchild, klass='box')) |
116 data.append(Section(children=boxchild, klass='box')) |
115 data.append(Section(children='', klass='vl')) |
117 data.append(Section(children='', klass='vl')) |
156 return layout |
158 return layout |
157 |
159 |
158 def visit_relationschema(self, rschema, title=True): |
160 def visit_relationschema(self, rschema, title=True): |
159 """get a layout for a relation schema""" |
161 """get a layout for a relation schema""" |
160 _ = self.req._ |
162 _ = self.req._ |
161 title = Link(self.rschema_link_url(rschema), rschema.type) |
163 if title: |
162 stereotypes = [] |
164 title = Link(self.rschema_link_url(rschema), rschema.type) |
163 if rschema.meta: |
165 stereotypes = [] |
164 stereotypes.append('meta') |
166 if rschema.meta: |
165 if rschema.symetric: |
167 stereotypes.append('meta') |
166 stereotypes.append('symetric') |
168 if rschema.symetric: |
167 if rschema.inlined: |
169 stereotypes.append('symetric') |
168 stereotypes.append('inlined') |
170 if rschema.inlined: |
169 title = Section(children=(title, ' (%s)'%rschema.display_name(self.req)), klass='title') |
171 stereotypes.append('inlined') |
170 if stereotypes: |
172 title = Section(children=(title, ' (%s)'%rschema.display_name(self.req)), klass='title') |
171 title.append(self.stereotype(','.join(stereotypes))) |
173 if stereotypes: |
172 layout = Section(children=(title,), klass='schema') |
174 title.append(self.stereotype(','.join(stereotypes))) |
|
175 layout = Section(children=(title,), klass='schema') |
|
176 else: |
|
177 layout = Section(klass='schema') |
173 data = [_('from'), _('to')] |
178 data = [_('from'), _('to')] |
174 schema = rschema.schema |
179 schema = rschema.schema |
175 rschema_objects = rschema.objects() |
180 rschema_objects = rschema.objects() |
176 if rschema_objects: |
181 if rschema_objects: |
177 # might be empty |
182 # might be empty |
200 elif val and isinstance(val, basestring): |
205 elif val and isinstance(val, basestring): |
201 val = _(val) |
206 val = _(val) |
202 else: |
207 else: |
203 val = str(val) |
208 val = str(val) |
204 data.append(Text(val)) |
209 data.append(Text(val)) |
205 table = Table(cols=cols, rheaders=1, children=data) |
210 table = Table(cols=cols, rheaders=1, children=data, klass='listing') |
206 layout.append(Section(children=(table,), klass='relationDefinition')) |
211 layout.append(Section(children=(table,), klass='relationDefinition')) |
207 if not self.req.cnx.anonymous_connection: |
212 if not self.req.cnx.anonymous_connection: |
208 layout.append(self.format_acls(rschema, ('read', 'add', 'delete'))) |
213 layout.append(self.format_acls(rschema, ('read', 'add', 'delete'))) |
209 layout.append(Section(children='', klass='clear')) |
214 layout.append(Section(children='', klass='clear')) |
210 return layout |
215 return layout |