Projet

Général

Profil

0001-workflows-allow-marking-a-status-as-terminal-1960.patch

Frédéric Péters, 22 novembre 2012 16:02

Télécharger (3,78 ko)

Voir les différences:

Subject: [PATCH] workflows: allow marking a status as terminal (#1960)

 wcs/admin/workflows.ptl |   23 ++++++++++++++++++++++-
 wcs/workflows.py        |   12 +++++++++---
 2 files changed, 31 insertions(+), 4 deletions(-)
wcs/admin/workflows.ptl
271 271

  
272 272
class WorkflowStatusPage(Directory):
273 273
    _q_exports = ['', 'delete', 'newitem', ('items', 'items_dir'),
274
                  'update_order', 'edit', 'reassign', 'visibility']
274
                  'update_order', 'edit', 'reassign', 'visibility',
275
                  'endpoint']
275 276

  
276 277
    def __init__(self, workflow, status_id):
277 278
        self.workflow = workflow
......
353 354
            '<ul>'
354 355
            '<li><a href="edit">%s</a></li>' % _('Change Status Name')
355 356
            '<li><a href="visibility" rel="popup">%s</a></li>' % _('Change Status Visibility')
357
            '<li><a href="endpoint" rel="popup">%s</a></li>' % _('Change Terminal Status')
356 358
            '<li><a href="delete" rel="popup">%s</a></li>' % _('Delete')
357 359
            '</ul>'
358 360
            '<div id="new-field">'
......
559 561
        '<h2>%s</h2>' % _('Edit Workflow Status Visibility')
560 562
        form.render()
561 563

  
564
    def endpoint [html] (self):
565
        form = Form(enctype = 'multipart/form-data')
566
        form.add(CheckboxWidget, 'force_terminal_status',
567
                 title=_('Force Terminal Status'),
568
                 value=(self.status.forced_endpoint == True))
569
        form.add_submit('submit', _('Submit'))
570
        form.add_submit('cancel', _('Cancel'))
571
        if form.get_widget('cancel').parse():
572
            return redirect('..')
573

  
574
        if form.is_submitted() and not form.has_errors():
575
            self.status.forced_endpoint = form.get_widget('force_terminal_status').parse()
576
            self.workflow.store()
577
            return redirect('.')
578

  
579
        html_top('workflows', title = _('Edit Terminal Status'))
580
        get_response().breadcrumb.append( ('endpoint', _('Terminal Status')) )
581
        form.render()
582

  
562 583

  
563 584
class WorkflowStatusDirectory(Directory):
564 585
    _q_exports = ['']
wcs/workflows.py
133 133
        for status in self.possible_status:
134 134
            waitpoint = False
135 135
            endpoint = True
136
            for item in status.items:
137
                endpoint = item.endpoint and endpoint
138
                waitpoint = item.waitpoint or waitpoint
136
            if status.forced_endpoint:
137
                endpoint = True
138
            else:
139
                for item in status.items:
140
                    endpoint = item.endpoint and endpoint
141
                    waitpoint = item.waitpoint or waitpoint
139 142
            if endpoint or waitpoint:
140 143
                waitpoint_status.append(status)
141 144
        return waitpoint_status
......
148 151
    def get_not_endpoint_status(self):
149 152
        not_endpoint_status = []
150 153
        for status in self.possible_status:
154
            if status.forced_endpoint:
155
                continue
151 156
            endpoint = True
152 157
            for item in status.items:
153 158
                endpoint = item.endpoint and endpoint
......
316 321
    name = None
317 322
    items = None
318 323
    visibility = None
324
    forced_endpoint = False
319 325

  
320 326
    def __init__(self, name = None):
321 327
        self.name = name
322
-