web/views/schema.py
changeset 2789 39712da6f397
parent 2617 89c62b855f2e
child 3230 1d25e928c299
equal deleted inserted replaced
2788:8d3dbe577d3a 2789:39712da6f397
   197 
   197 
   198 class CWETypeOneLineView(baseviews.OneLineView):
   198 class CWETypeOneLineView(baseviews.OneLineView):
   199     __select__ = implements('CWEType')
   199     __select__ = implements('CWEType')
   200 
   200 
   201     def cell_call(self, row, col, **kwargs):
   201     def cell_call(self, row, col, **kwargs):
   202         entity = self.entity(row, col)
   202         entity = self.rset.get_entity(row, col)
   203         final = entity.final
   203         final = entity.final
   204         if final:
   204         if final:
   205             self.w(u'<em class="finalentity">')
   205             self.w(u'<em class="finalentity">')
   206         super(CWETypeOneLineView, self).cell_call(row, col, **kwargs)
   206         super(CWETypeOneLineView, self).cell_call(row, col, **kwargs)
   207         if final:
   207         if final:
   225 class CWETypeSTextView(EntityView):
   225 class CWETypeSTextView(EntityView):
   226     id = 'cwetype-schema-text'
   226     id = 'cwetype-schema-text'
   227     __select__ = EntityView.__select__ & implements('CWEType')
   227     __select__ = EntityView.__select__ & implements('CWEType')
   228 
   228 
   229     def cell_call(self, row, col):
   229     def cell_call(self, row, col):
   230         entity = self.entity(row, col)
   230         entity = self.rset.get_entity(row, col)
   231         self.w(u'<h2>%s</h2>' % _('Attributes'))
   231         self.w(u'<h2>%s</h2>' % _('Attributes'))
   232         rset = self.req.execute('Any N,F,D,I,J,DE,A '
   232         rset = self.req.execute('Any N,F,D,I,J,DE,A '
   233                                 'ORDERBY AA WHERE A is CWAttribute, '
   233                                 'ORDERBY AA WHERE A is CWAttribute, '
   234                                 'A ordernum AA, A defaultval D, '
   234                                 'A ordernum AA, A defaultval D, '
   235                                 'A description DE, '
   235                                 'A description DE, '
   261 class CWETypeSImageView(EntityView):
   261 class CWETypeSImageView(EntityView):
   262     id = 'cwetype-schema-image'
   262     id = 'cwetype-schema-image'
   263     __select__ = EntityView.__select__ & implements('CWEType')
   263     __select__ = EntityView.__select__ & implements('CWEType')
   264 
   264 
   265     def cell_call(self, row, col):
   265     def cell_call(self, row, col):
   266         entity = self.entity(row, col)
   266         entity = self.rset.get_entity(row, col)
   267         url = entity.absolute_url(vid='schemagraph')
   267         url = entity.absolute_url(vid='schemagraph')
   268         self.w(u'<img src="%s" alt="%s"/>' % (
   268         self.w(u'<img src="%s" alt="%s"/>' % (
   269             xml_escape(url),
   269             xml_escape(url),
   270             xml_escape(self.req._('graphical schema for %s') % entity.name)))
   270             xml_escape(self.req._('graphical schema for %s') % entity.name)))
   271 
   271 
   272 class CWETypeSPermView(EntityView):
   272 class CWETypeSPermView(EntityView):
   273     id = 'cwetype-schema-permissions'
   273     id = 'cwetype-schema-permissions'
   274     __select__ = EntityView.__select__ & implements('CWEType')
   274     __select__ = EntityView.__select__ & implements('CWEType')
   275 
   275 
   276     def cell_call(self, row, col):
   276     def cell_call(self, row, col):
   277         entity = self.entity(row, col)
   277         entity = self.rset.get_entity(row, col)
   278         self.w(u'<h2>%s</h2>' % _('Add permissions'))
   278         self.w(u'<h2>%s</h2>' % _('Add permissions'))
   279         rset = self.req.execute('Any P WHERE X add_permission P, '
   279         rset = self.req.execute('Any P WHERE X add_permission P, '
   280                                 'X eid %(x)s',
   280                                 'X eid %(x)s',
   281                                 {'x': entity.eid})
   281                                 {'x': entity.eid})
   282         self.wview('outofcontext', rset, 'null')
   282         self.wview('outofcontext', rset, 'null')
   299 class CWETypeSWorkflowView(EntityView):
   299 class CWETypeSWorkflowView(EntityView):
   300     id = 'cwetype-workflow'
   300     id = 'cwetype-workflow'
   301     __select__ = EntityView.__select__ & implements('CWEType')
   301     __select__ = EntityView.__select__ & implements('CWEType')
   302 
   302 
   303     def cell_call(self, row, col):
   303     def cell_call(self, row, col):
   304         entity = self.entity(row, col)
   304         entity = self.rset.get_entity(row, col)
   305         if entity.reverse_state_of:
   305         if entity.reverse_state_of:
   306             self.w(u'<img src="%s" alt="%s"/>' % (
   306             self.w(u'<img src="%s" alt="%s"/>' % (
   307                     xml_escape(entity.absolute_url(vid='ewfgraph')),
   307                     xml_escape(entity.absolute_url(vid='ewfgraph')),
   308                     xml_escape(self.req._('graphical workflow for %s') % entity.name)))
   308                     xml_escape(self.req._('graphical workflow for %s') % entity.name)))
   309         else:
   309         else:
   375     __select__ = implements('CWEType')
   375     __select__ = implements('CWEType')
   376     content_type = 'image/png'
   376     content_type = 'image/png'
   377 
   377 
   378     def _generate(self, tmpfile):
   378     def _generate(self, tmpfile):
   379         """display schema information for an entity"""
   379         """display schema information for an entity"""
   380         entity = self.entity(self.row, self.col)
   380         entity = self.rset.get_entity(self.row, self.col)
   381         eschema = self.vreg.schema.eschema(entity.name)
   381         eschema = self.vreg.schema.eschema(entity.name)
   382         visitor = OneHopESchemaVisitor(self.req, eschema,
   382         visitor = OneHopESchemaVisitor(self.req, eschema,
   383                                        skiptypes=skip_types(self.req))
   383                                        skiptypes=skip_types(self.req))
   384         s2d.schema2dot(outputfile=tmpfile, visitor=visitor)
   384         s2d.schema2dot(outputfile=tmpfile, visitor=visitor)
   385 
   385 
   387 class CWRTypeSchemaImageView(CWETypeSchemaImageView):
   387 class CWRTypeSchemaImageView(CWETypeSchemaImageView):
   388     __select__ = implements('CWRType')
   388     __select__ = implements('CWRType')
   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         rschema = self.vreg.schema.rschema(entity.name)
   393         rschema = self.vreg.schema.rschema(entity.name)
   394         visitor = OneHopRSchemaVisitor(self.req, rschema)
   394         visitor = OneHopRSchemaVisitor(self.req, rschema)
   395         s2d.schema2dot(outputfile=tmpfile, visitor=visitor)
   395         s2d.schema2dot(outputfile=tmpfile, visitor=visitor)
   396 
   396 
   397 
   397