Exemplo n.º 1
0
def run_task(request):
    if request.method == "POST":
        tasks = Task.objects.filter(job_status=STATUS_LOOKUP["NOTDONE"])
        if request.POST.get("site", "") != "":
            tasks = tasks.filter(site__id=request.POST["site"])
        for t in tasks:
            can_execute = True
            for pred in t.predecessors.all():
                if pred.job_status != STATUS_LOOKUP["DONE"]:
                    can_execute = False
                    break
            if can_execute:
                print "Executing task"
                run_process_task(t)

        tasks = Task.objects.filter(job_status=STATUS_LOOKUP["TRANSFER_BACK"])
        for t in tasks:
            print "Executing task"
            run_process_task(t)
        return redirect(request.POST["next"])
Exemplo n.º 2
0
def finish_task(request):
    if request.method == "POST":
        if request.POST.get("task_id","") != "":
            user = request.user
            task_id = request.POST["task_id"]
            task = Task.objects.get(id=task_id)
            if task.assignee == user:
                transfer_back(task)
        elif request.POST.get("validate_task", "") != "":
            user= request.user
            task_id = request.POST["validate_task"]
            task = Task.objects.get(id=task_id)
            if user.has_perm('web.can_edit'):
                finish_process_task(task)
            pass
        elif request.POST.get("retry_task", "") != "":
            task_id = request.POST["retry_task"]
            task = Task.objects.get(id=task_id)
            run_process_task(task)
        return redirect('web.views.task', site=task.site.id, task_id=task.id)