198 |
198 |
199 class CWETypeOneLineView(baseviews.OneLineView): |
199 class CWETypeOneLineView(baseviews.OneLineView): |
200 __select__ = implements('CWEType') |
200 __select__ = implements('CWEType') |
201 |
201 |
202 def cell_call(self, row, col, **kwargs): |
202 def cell_call(self, row, col, **kwargs): |
203 entity = self.entity(row, col) |
203 entity = self.rset.get_entity(row, col) |
204 final = entity.final |
204 final = entity.final |
205 if final: |
205 if final: |
206 self.w(u'<em class="finalentity">') |
206 self.w(u'<em class="finalentity">') |
207 super(CWETypeOneLineView, self).cell_call(row, col, **kwargs) |
207 super(CWETypeOneLineView, self).cell_call(row, col, **kwargs) |
208 if final: |
208 if final: |
226 class CWETypeSTextView(EntityView): |
226 class CWETypeSTextView(EntityView): |
227 id = 'cwetype-schema-text' |
227 id = 'cwetype-schema-text' |
228 __select__ = EntityView.__select__ & implements('CWEType') |
228 __select__ = EntityView.__select__ & implements('CWEType') |
229 |
229 |
230 def cell_call(self, row, col): |
230 def cell_call(self, row, col): |
231 entity = self.entity(row, col) |
231 entity = self.rset.get_entity(row, col) |
232 self.w(u'<h2>%s</h2>' % _('Attributes')) |
232 self.w(u'<h2>%s</h2>' % _('Attributes')) |
233 rset = self.req.execute('Any N,F,D,I,J,DE,A ' |
233 rset = self.req.execute('Any N,F,D,I,J,DE,A ' |
234 'ORDERBY AA WHERE A is CWAttribute, ' |
234 'ORDERBY AA WHERE A is CWAttribute, ' |
235 'A ordernum AA, A defaultval D, ' |
235 'A ordernum AA, A defaultval D, ' |
236 'A description DE, ' |
236 'A description DE, ' |
262 class CWETypeSImageView(EntityView): |
262 class CWETypeSImageView(EntityView): |
263 id = 'cwetype-schema-image' |
263 id = 'cwetype-schema-image' |
264 __select__ = EntityView.__select__ & implements('CWEType') |
264 __select__ = EntityView.__select__ & implements('CWEType') |
265 |
265 |
266 def cell_call(self, row, col): |
266 def cell_call(self, row, col): |
267 entity = self.entity(row, col) |
267 entity = self.rset.get_entity(row, col) |
268 url = entity.absolute_url(vid='schemagraph') |
268 url = entity.absolute_url(vid='schemagraph') |
269 self.w(u'<img src="%s" alt="%s"/>' % ( |
269 self.w(u'<img src="%s" alt="%s"/>' % ( |
270 xml_escape(url), |
270 xml_escape(url), |
271 xml_escape(self.req._('graphical schema for %s') % entity.name))) |
271 xml_escape(self.req._('graphical schema for %s') % entity.name))) |
272 |
272 |
274 class CWETypeSPermView(EntityView): |
274 class CWETypeSPermView(EntityView): |
275 id = 'cwetype-schema-permissions' |
275 id = 'cwetype-schema-permissions' |
276 __select__ = EntityView.__select__ & implements('CWEType') |
276 __select__ = EntityView.__select__ & implements('CWEType') |
277 |
277 |
278 def cell_call(self, row, col): |
278 def cell_call(self, row, col): |
279 entity = self.entity(row, col) |
279 entity = self.rset.get_entity(row, col) |
280 self.w(u'<h2>%s</h2>' % _('Add permissions')) |
280 self.w(u'<h2>%s</h2>' % _('Add permissions')) |
281 rset = self.req.execute('Any P WHERE X add_permission P, ' |
281 rset = self.req.execute('Any P WHERE X add_permission P, ' |
282 'X eid %(x)s', |
282 'X eid %(x)s', |
283 {'x': entity.eid}) |
283 {'x': entity.eid}) |
284 self.wview('outofcontext', rset, 'null') |
284 self.wview('outofcontext', rset, 'null') |
303 id = 'cwetype-workflow' |
303 id = 'cwetype-workflow' |
304 __select__ = (EntityView.__select__ & implements('CWEType') & |
304 __select__ = (EntityView.__select__ & implements('CWEType') & |
305 has_related_entities('workflow_of', 'object')) |
305 has_related_entities('workflow_of', 'object')) |
306 |
306 |
307 def cell_call(self, row, col): |
307 def cell_call(self, row, col): |
308 entity = self.entity(row, col) |
308 entity = self.rset.get_entity(row, col) |
309 if entity.default_workflow: |
309 if entity.default_workflow: |
310 wf = entity.default_workflow[0] |
310 wf = entity.default_workflow[0] |
311 self.w(u'<h1>%s (%s)</h1>' % (wf.name, self.req._('default'))) |
311 self.w(u'<h1>%s (%s)</h1>' % (wf.name, self.req._('default'))) |
312 self.wf_image(wf) |
312 self.wf_image(wf) |
313 for altwf in entity.reverse_workflow_of: |
313 for altwf in entity.reverse_workflow_of: |
387 __select__ = implements('CWEType') |
387 __select__ = implements('CWEType') |
388 content_type = 'image/png' |
388 content_type = 'image/png' |
389 |
389 |
390 def _generate(self, tmpfile): |
390 def _generate(self, tmpfile): |
391 """display schema information for an entity""" |
391 """display schema information for an entity""" |
392 entity = self.entity(self.row, self.col) |
392 entity = self.rset.get_entity(self.row, self.col) |
393 eschema = self.vreg.schema.eschema(entity.name) |
393 eschema = self.vreg.schema.eschema(entity.name) |
394 visitor = OneHopESchemaVisitor(self.req, eschema, |
394 visitor = OneHopESchemaVisitor(self.req, eschema, |
395 skiptypes=skip_types(self.req)) |
395 skiptypes=skip_types(self.req)) |
396 s2d.schema2dot(outputfile=tmpfile, visitor=visitor) |
396 s2d.schema2dot(outputfile=tmpfile, visitor=visitor) |
397 |
397 |
399 class CWRTypeSchemaImageView(CWETypeSchemaImageView): |
399 class CWRTypeSchemaImageView(CWETypeSchemaImageView): |
400 __select__ = implements('CWRType') |
400 __select__ = implements('CWRType') |
401 |
401 |
402 def _generate(self, tmpfile): |
402 def _generate(self, tmpfile): |
403 """display schema information for an entity""" |
403 """display schema information for an entity""" |
404 entity = self.entity(self.row, self.col) |
404 entity = self.rset.get_entity(self.row, self.col) |
405 rschema = self.vreg.schema.rschema(entity.name) |
405 rschema = self.vreg.schema.rschema(entity.name) |
406 visitor = OneHopRSchemaVisitor(self.req, rschema) |
406 visitor = OneHopRSchemaVisitor(self.req, rschema) |
407 s2d.schema2dot(outputfile=tmpfile, visitor=visitor) |
407 s2d.schema2dot(outputfile=tmpfile, visitor=visitor) |
408 |
408 |
409 |
409 |