def ls(workflow): """ List all workflows, or all stages in a workflow is a workflow.id is passed. `workflow` can be a workflow.id or the name of the workflow. """ if workflow: print workflow wf = Workflow.objects.get(pk=workflow) if representsInt(workflow) else Workflow.objects.get(name=workflow) print wf print wf.describe() for s in wf.stages: print "\t{0.order_in_workflow}) {0}".format(s) else: for w in Workflow.objects.all(): print w
def rm(workflows,prompt_confirm,stage_number,all_stages_after): """ Deletes a workflow """ workflows = [ Workflow.objects.get(pk=w) if representsInt(w) else Workflow.objects.get(name=w) for w in workflows.split(',') ] for wf in workflows: if stage_number: stage = wf.stages.get(order_in_workflow=stage_number) if not prompt_confirm or confirm('Are you sure you want to delete {0}{1}{2}?'. format(wf,stage,' and all stages after it' if all_stages_after else ''), default=False,timeout=60): for s in wf.stages.filter(order_in_workflow__gt=stage.order_in_workflow-1) if all_stages_after else wf.stages.filter(order_in_workflow = stage.order_in_workflow): s.delete() else: if not prompt_confirm or confirm('Are you sure you want to delete {0}?'.format(wf),default=False,timeout=60): wf.delete()