web/views/workflow.py
branchtls-sprint
changeset 1398 5fe84a5f7035
parent 1318 50e1a778c5ee
child 1504 c6051f141807
equal deleted inserted replaced
1397:6cbc7bc8ea6d 1398:5fe84a5f7035
    84         eid = self.rset[row][col]
    84         eid = self.rset[row][col]
    85         sel = 'Any FS,TS,WF,D'
    85         sel = 'Any FS,TS,WF,D'
    86         rql = ' ORDERBY D DESC WHERE WF wf_info_for X,'\
    86         rql = ' ORDERBY D DESC WHERE WF wf_info_for X,'\
    87               'WF from_state FS, WF to_state TS, WF comment C,'\
    87               'WF from_state FS, WF to_state TS, WF comment C,'\
    88               'WF creation_date D'
    88               'WF creation_date D'
    89         if self.vreg.schema.eschema('EUser').has_perm(self.req, 'read'):
    89         if self.vreg.schema.eschema('CWUser').has_perm(self.req, 'read'):
    90             sel += ',U,C'
    90             sel += ',U,C'
    91             rql += ', WF owned_by U?'
    91             rql += ', WF owned_by U?'
    92             displaycols = range(5)
    92             displaycols = range(5)
    93             headers = (_('from_state'), _('to_state'), _('comment'), _('date'),
    93             headers = (_('from_state'), _('to_state'), _('comment'), _('date'),
    94                        _('EUser'))            
    94                        _('CWUser'))            
    95         else:
    95         else:
    96             sel += ',C'
    96             sel += ',C'
    97             displaycols = range(4)
    97             displaycols = range(4)
    98             headers = (_('from_state'), _('to_state'), _('comment'), _('date'))
    98             headers = (_('from_state'), _('to_state'), _('comment'), _('date'))
    99         rql = '%s %s, X eid %%(x)s' % (sel, rql)
    99         rql = '%s %s, X eid %%(x)s' % (sel, rql)
   128 
   128 
   129 # workflow images #############################################################
   129 # workflow images #############################################################
   130         
   130         
   131 class ViewWorkflowAction(action.Action):
   131 class ViewWorkflowAction(action.Action):
   132     id = 'workflow'
   132     id = 'workflow'
   133     __select__ = implements('EEType') & has_related_entities('state_of', 'object')
   133     __select__ = implements('CWEType') & has_related_entities('state_of', 'object')
   134     
   134     
   135     category = 'mainactions'
   135     category = 'mainactions'
   136     title = _('view workflow')
   136     title = _('view workflow')
   137     def url(self):
   137     def url(self):
   138         entity = self.rset.get_entity(self.row or 0, self.col or 0)
   138         entity = self.rset.get_entity(self.row or 0, self.col or 0)
   139         return entity.absolute_url(vid='workflow')
   139         return entity.absolute_url(vid='workflow')
   140 
   140 
   141         
   141         
   142 class EETypeWorkflowView(view.EntityView):
   142 class CWETypeWorkflowView(view.EntityView):
   143     id = 'workflow'
   143     id = 'workflow'
   144     __select__ = implements('EEType')
   144     __select__ = implements('CWEType')
   145     cache_max_age = 60*60*2 # stay in http cache for 2 hours by default 
   145     cache_max_age = 60*60*2 # stay in http cache for 2 hours by default 
   146     
   146     
   147     def cell_call(self, row, col, **kwargs):
   147     def cell_call(self, row, col, **kwargs):
   148         entity = self.entity(row, col)
   148         entity = self.entity(row, col)
   149         self.w(u'<h1>%s</h1>' % (self.req._('workflow for %s')
   149         self.w(u'<h1>%s</h1>' % (self.req._('workflow for %s')
   203             for incomingstate in transition.reverse_allowed_transition:
   203             for incomingstate in transition.reverse_allowed_transition:
   204                 yield incomingstate.eid, transition.eid, transition
   204                 yield incomingstate.eid, transition.eid, transition
   205             yield transition.eid, transition.destination().eid, transition
   205             yield transition.eid, transition.destination().eid, transition
   206 
   206 
   207 
   207 
   208 class EETypeWorkflowImageView(TmpFileViewMixin, view.EntityView):
   208 class CWETypeWorkflowImageView(TmpFileViewMixin, view.EntityView):
   209     id = 'ewfgraph'
   209     id = 'ewfgraph'
   210     content_type = 'image/png'
   210     content_type = 'image/png'
   211     __select__ = implements('EEType')
   211     __select__ = implements('CWEType')
   212     
   212     
   213     def _generate(self, tmpfile):
   213     def _generate(self, tmpfile):
   214         """display schema information for an entity"""
   214         """display schema information for an entity"""
   215         entity = self.entity(self.row, self.col)
   215         entity = self.entity(self.row, self.col)
   216         visitor = WorkflowVisitor(entity)
   216         visitor = WorkflowVisitor(entity)