88 skiptypes = skip_types(self._cw) |
88 skiptypes = skip_types(self._cw) |
89 formparams = {} |
89 formparams = {} |
90 formparams['sec'] = self.__regid__ |
90 formparams['sec'] = self.__regid__ |
91 if not skiptypes: |
91 if not skiptypes: |
92 formparams['skipmeta'] = u'0' |
92 formparams['skipmeta'] = u'0' |
93 schema = self._cw.schema |
93 schema = self._cw.vreg.schema |
94 # compute entities |
94 # compute entities |
95 entities = sorted(eschema for eschema in schema.entities() |
95 entities = sorted(eschema for eschema in schema.entities() |
96 if not (eschema.final or eschema in skiptypes)) |
96 if not (eschema.final or eschema in skiptypes)) |
97 # compute relations |
97 # compute relations |
98 if display_relations: |
98 if display_relations: |
137 url = xml_escape(self._cw.build_url('schema', **formparams) + '#index') |
137 url = xml_escape(self._cw.build_url('schema', **formparams) + '#index') |
138 self.w(u'<a href="%s"><img src="%s" alt="%s"/></a>' % ( |
138 self.w(u'<a href="%s"><img src="%s" alt="%s"/></a>' % ( |
139 url, self._cw.external_resource('UP_ICON'), _('up'))) |
139 url, self._cw.external_resource('UP_ICON'), _('up'))) |
140 self.w(u'</h3>') |
140 self.w(u'</h3>') |
141 self.w(u'<div style="margin: 0px 1.5em">') |
141 self.w(u'<div style="margin: 0px 1.5em">') |
142 self._cw.schema_definition(eschema, link=False) |
142 self._cw.vreg.schema_definition(eschema, link=False) |
143 # display entity attributes only if they have some permissions modified |
143 # display entity attributes only if they have some permissions modified |
144 modified_attrs = [] |
144 modified_attrs = [] |
145 for attr, etype in eschema.attribute_definitions(): |
145 for attr, etype in eschema.attribute_definitions(): |
146 if self.has_schema_modified_permissions(attr, attr.ACTIONS): |
146 if self.has_schema_modified_permissions(attr, attr.ACTIONS): |
147 modified_attrs.append(attr) |
147 modified_attrs.append(attr) |
149 self.w(u'<h4>%s</h4>' % _('attributes with modified permissions:').capitalize()) |
149 self.w(u'<h4>%s</h4>' % _('attributes with modified permissions:').capitalize()) |
150 self.w(u'</div>') |
150 self.w(u'</div>') |
151 self.w(u'<div style="margin: 0px 6em">') |
151 self.w(u'<div style="margin: 0px 6em">') |
152 for attr in modified_attrs: |
152 for attr in modified_attrs: |
153 self.w(u'<h4 class="schema">%s (%s)</h4> ' % (attr.type, _(attr.type))) |
153 self.w(u'<h4 class="schema">%s (%s)</h4> ' % (attr.type, _(attr.type))) |
154 self._cw.schema_definition(attr, link=False) |
154 self._cw.vreg.schema_definition(attr, link=False) |
155 self.w(u'</div>') |
155 self.w(u'</div>') |
156 |
156 |
157 def display_relations(self, relations, formparams): |
157 def display_relations(self, relations, formparams): |
158 _ = self._cw._ |
158 _ = self._cw._ |
159 self.w(u'<a id="relations" href="relations"/>') |
159 self.w(u'<a id="relations" href="relations"/>') |
173 ', '.join(_(str(subj)) for subj in rschema.subjects()))) |
173 ', '.join(_(str(subj)) for subj in rschema.subjects()))) |
174 self.w(u'<div><strong>%s</strong> %s (%s)</div>' % ( |
174 self.w(u'<div><strong>%s</strong> %s (%s)</div>' % ( |
175 _('object_plural:'), |
175 _('object_plural:'), |
176 ', '.join(str(obj) for obj in rschema.objects()), |
176 ', '.join(str(obj) for obj in rschema.objects()), |
177 ', '.join(_(str(obj)) for obj in rschema.objects()))) |
177 ', '.join(_(str(obj)) for obj in rschema.objects()))) |
178 self._cw.schema_definition(rschema, link=False) |
178 self._cw.vreg.schema_definition(rschema, link=False) |
179 self.w(u'</div>') |
179 self.w(u'</div>') |
180 |
180 |
181 |
181 |
182 class SchemaUreportsView(StartupView): |
182 class SchemaUreportsView(StartupView): |
183 __regid__ = 'schema-block' |
183 __regid__ = 'schema-block' |
184 |
184 |
185 def call(self): |
185 def call(self): |
186 viewer = SchemaViewer(self._cw) |
186 viewer = SchemaViewer(self._cw) |
187 layout = viewer.visit_schema(self._cw.schema, display_relations=True, |
187 layout = viewer.visit_schema(self._cw.vreg.schema, display_relations=True, |
188 skiptypes=skip_types(self._cw)) |
188 skiptypes=skip_types(self._cw)) |
189 self.w(uilib.ureport_as_html(layout)) |
189 self.w(uilib.ureport_as_html(layout)) |
190 |
190 |
191 |
191 |
192 # CWAttribute / CWRelation ##################################################### |
192 # CWAttribute / CWRelation ##################################################### |
382 content_type = 'image/png' |
382 content_type = 'image/png' |
383 |
383 |
384 def _generate(self, tmpfile): |
384 def _generate(self, tmpfile): |
385 """display global schema information""" |
385 """display global schema information""" |
386 print 'skipedtypes', skip_types(self._cw) |
386 print 'skipedtypes', skip_types(self._cw) |
387 visitor = FullSchemaVisitor(self._cw, self._cw.schema, |
387 visitor = FullSchemaVisitor(self._cw, self._cw.vreg.schema, |
388 skiptypes=skip_types(self._cw)) |
388 skiptypes=skip_types(self._cw)) |
389 s2d.schema2dot(outputfile=tmpfile, visitor=visitor) |
389 s2d.schema2dot(outputfile=tmpfile, visitor=visitor) |
390 |
390 |
391 |
391 |
392 class CWETypeSchemaImageView(TmpFileViewMixin, EntityView): |
392 class CWETypeSchemaImageView(TmpFileViewMixin, EntityView): |