workflows: allow marking a status as terminal
This commit is contained in:
parent
ed8b18268f
commit
af78aecfac
|
@ -272,7 +272,8 @@ class WorkflowItemsDir(Directory):
|
|||
|
||||
class WorkflowStatusPage(Directory):
|
||||
_q_exports = ['', 'delete', 'newitem', ('items', 'items_dir'),
|
||||
'update_order', 'edit', 'reassign', 'visibility']
|
||||
'update_order', 'edit', 'reassign', 'visibility',
|
||||
'force_endpoint', 'unforce_endpoint']
|
||||
|
||||
def __init__(self, workflow, status_id):
|
||||
self.workflow = workflow
|
||||
|
@ -354,6 +355,10 @@ class WorkflowStatusPage(Directory):
|
|||
'<ul>'
|
||||
'<li><a href="edit">%s</a></li>' % _('Change Status Name')
|
||||
'<li><a href="visibility" rel="popup">%s</a></li>' % _('Change Status Visibility')
|
||||
if not self.status.forced_endpoint:
|
||||
'<li><a href="force_endpoint">%s</a></li>' % _('Mark the Status as Terminal')
|
||||
else:
|
||||
'<li><a href="unforce_endpoint">%s</a></li>' % _('Unmark the Status as Terminal')
|
||||
'<li><a href="delete" rel="popup">%s</a></li>' % _('Delete')
|
||||
'</ul>'
|
||||
'<div id="new-field">'
|
||||
|
@ -553,6 +558,16 @@ class WorkflowStatusPage(Directory):
|
|||
'<h2>%s</h2>' % _('Edit Workflow Status Visibility')
|
||||
form.render()
|
||||
|
||||
def force_endpoint(self):
|
||||
self.status.forced_endpoint = True
|
||||
self.workflow.store()
|
||||
return redirect('.')
|
||||
|
||||
def unforce_endpoint(self):
|
||||
self.status.forced_endpoint = False
|
||||
self.workflow.store()
|
||||
return redirect('.')
|
||||
|
||||
|
||||
class WorkflowStatusDirectory(Directory):
|
||||
_q_exports = ['']
|
||||
|
|
|
@ -133,9 +133,12 @@ class Workflow(StorableObject):
|
|||
for status in self.possible_status:
|
||||
waitpoint = False
|
||||
endpoint = True
|
||||
for item in status.items:
|
||||
endpoint = item.endpoint and endpoint
|
||||
waitpoint = item.waitpoint or waitpoint
|
||||
if status.forced_endpoint:
|
||||
endpoint = True
|
||||
else:
|
||||
for item in status.items:
|
||||
endpoint = item.endpoint and endpoint
|
||||
waitpoint = item.waitpoint or waitpoint
|
||||
if endpoint or waitpoint:
|
||||
waitpoint_status.append(status)
|
||||
return waitpoint_status
|
||||
|
@ -148,6 +151,8 @@ class Workflow(StorableObject):
|
|||
def get_not_endpoint_status(self):
|
||||
not_endpoint_status = []
|
||||
for status in self.possible_status:
|
||||
if status.forced_endpoint:
|
||||
continue
|
||||
endpoint = True
|
||||
for item in status.items:
|
||||
endpoint = item.endpoint and endpoint
|
||||
|
@ -335,6 +340,7 @@ class WorkflowStatus:
|
|||
name = None
|
||||
items = None
|
||||
visibility = None
|
||||
forced_endpoint = False
|
||||
|
||||
def __init__(self, name = None):
|
||||
self.name = name
|
||||
|
|
Loading…
Reference in New Issue