web/views/workflow.py
changeset 3369 7b88d12b4ee2
parent 3293 69c0ba095536
parent 3350 fa77640a9155
child 3377 dd9d292b6a6d
equal deleted inserted replaced
3300:c7c4775a5619 3369:7b88d12b4ee2
    27 _abaa = uicfg.actionbox_appearsin_addmenu
    27 _abaa = uicfg.actionbox_appearsin_addmenu
    28 _abaa.tag_subject_of(('BaseTransition', 'condition', 'RQLExpression'), False)
    28 _abaa.tag_subject_of(('BaseTransition', 'condition', 'RQLExpression'), False)
    29 _abaa.tag_subject_of(('State', 'allowed_transition', 'BaseTransition'), False)
    29 _abaa.tag_subject_of(('State', 'allowed_transition', 'BaseTransition'), False)
    30 _abaa.tag_object_of(('SubWorkflowExitPoint', 'destination_state', 'State'),
    30 _abaa.tag_object_of(('SubWorkflowExitPoint', 'destination_state', 'State'),
    31                     False)
    31                     False)
       
    32 _abaa.tag_object_of(('State', 'state_of', 'Workflow'), True)
       
    33 _abaa.tag_object_of(('Transition', 'transition_of', 'Workflow'), True)
       
    34 _abaa.tag_object_of(('WorkflowTransition', 'transition_of', 'Workflow'), True)
       
    35 
       
    36 _afs = uicfg.autoform_section
       
    37 _afs.tag_subject_of(('TrInfo', 'to_state', '*'), 'generated')
       
    38 _afs.tag_subject_of(('TrInfo', 'from_state', '*'), 'generated')
       
    39 _afs.tag_object_of(('State', 'allowed_transition', '*'), 'primary')
       
    40 
    32 
    41 
    33 # IWorkflowable views #########################################################
    42 # IWorkflowable views #########################################################
    34 
    43 
    35 class ChangeStateForm(forms.CompositeEntityForm):
    44 class ChangeStateForm(forms.CompositeEntityForm):
    36     id = 'changestate'
    45     id = 'changestate'
    41 
    50 
    42 
    51 
    43 class ChangeStateFormView(form.FormViewMixIn, view.EntityView):
    52 class ChangeStateFormView(form.FormViewMixIn, view.EntityView):
    44     id = 'statuschange'
    53     id = 'statuschange'
    45     title = _('status change')
    54     title = _('status change')
    46     __select__ = implements(IWorkflowable) & match_form_params('treid')
    55     __select__ = (one_line_rset() & implements(IWorkflowable)
       
    56                   & match_form_params('treid'))
    47 
    57 
    48     def cell_call(self, row, col):
    58     def cell_call(self, row, col):
    49         entity = self.rset.get_entity(row, col)
    59         entity = self.rset.get_entity(row, col)
    50         transition = self.req.entity_from_eid(self.req.form['treid'])
    60         transition = self.req.entity_from_eid(self.req.form['treid'])
    51         dest = transition.destination()
    61         dest = transition.destination()
    52         _ = self.req._
    62         _ = self.req._
    53         form = self.vreg['forms'].select('changestate', self.req, entity=entity,
    63         # specify both rset/row/col and entity in case implements selector (and
    54                                          redirect_path=self.redirectpath(entity))
    64         # not entity_implements) is used on custom form
       
    65         form = self.vreg['forms'].select(
       
    66             'changestate', self.req, rset=self.rset, row=row, col=col,
       
    67             entity=entity, transition=transition,
       
    68             redirect_path=self.redirectpath(entity))
    55         self.w(form.error_message())
    69         self.w(form.error_message())
    56         self.w(u'<h4>%s %s</h4>\n' % (_(transition.name),
    70         self.w(u'<h4>%s %s</h4>\n' % (_(transition.name),
    57                                       entity.view('oneline')))
    71                                       entity.view('oneline')))
    58         msg = _('status will change from %(st1)s to %(st2)s') % {
    72         msg = _('status will change from %(st1)s to %(st2)s') % {
    59             'st1': _(entity.current_state.name),
    73             'st1': _(entity.current_state.name),
   185     def __init__(self, req):
   199     def __init__(self, req):
   186         self._ = req._
   200         self._ = req._
   187 
   201 
   188     def node_properties(self, stateortransition):
   202     def node_properties(self, stateortransition):
   189         """return default DOT drawing options for a state or transition"""
   203         """return default DOT drawing options for a state or transition"""
   190         props = {'label': stateortransition.name,
   204         props = {'label': stateortransition.printable_value('name'),
   191                  'fontname': 'Courier'}
   205                  'fontname': 'Courier'}
   192         if hasattr(stateortransition, 'state_of'):
   206         if hasattr(stateortransition, 'state_of'):
   193             props['shape'] = 'box'
   207             props['shape'] = 'box'
   194             props['style'] = 'filled'
   208             props['style'] = 'filled'
   195             if stateortransition.reverse_initial_state:
   209             if stateortransition.reverse_initial_state:
   199             descr = []
   213             descr = []
   200             tr = stateortransition
   214             tr = stateortransition
   201             if tr.require_group:
   215             if tr.require_group:
   202                 descr.append('%s %s'% (
   216                 descr.append('%s %s'% (
   203                     self._('groups:'),
   217                     self._('groups:'),
   204                     ','.join(g.name for g in tr.require_group)))
   218                     ','.join(g.printable_value('name') for g in tr.require_group)))
   205             if tr.condition:
   219             if tr.condition:
   206                 descr.append('%s %s'% (
   220                 descr.append('%s %s'% (
   207                     self._('condition:'),
   221                     self._('condition:'),
   208                     ' | '.join(e.expression for e in tr.condition)))
   222                     ' | '.join(e.expression for e in tr.condition)))
   209             if descr:
   223             if descr: