Skip to content

Instantly share code, notes, and snippets.

@kmmbvnr
Created July 13, 2016 02:11
Show Gist options
  • Save kmmbvnr/71523ace0bae58ffac589dbee5db6db8 to your computer and use it in GitHub Desktop.
Save kmmbvnr/71523ace0bae58ffac589dbee5db6db8 to your computer and use it in GitHub Desktop.
class Task(Model):
@contextmanager
def activate(self):
activation = self.flow_task.activation_cls(self.task)
with activation.lock():
yield activation
def start_view(request, start_task):
with start_task.activate() as activation:
activateion.prepare()
if request.POST:
activation.done()
return render(request, 'start.html', {
'activation': activation
})
def task_view(request, task_pk):
task = get_object_or_404(Task, pk=task_pk)
with task.activate() as activation:
activateion.prepare()
if request.POST:
activation.done()
return render(request, 'start.html', {
'activation': activation
})
def func(task):
with task.activate() as activation:
activation.done()
def signal_hanler(sender, **kwargs):
with kwargs['task'].activate() as activation:
activation.done()
class MyFlow(Flow):
start = (
flow.Start(start_view)
.Next(this.task)
)
task = (
flow.View(task_view)
.Next(this.end)
)
end = flow.End()
urls = [
MyFlow.instance.urls(
url('^$', viewflow.ProcessListView.as_view(), name='index'),
url('^tasks/$', viewflow.TaskListView.as_view(), name='tasks')
url('^queue/$', viewflow.QueueListView.as_view(), name='queue'),
url('^details/(?P<process_pk>\d+)/$', viewflow.DetailProcessView.as_view(), name='details'),
),
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment