Example #1
0
def edit_workflow(request, workflow):
  WorkflowFormSet = inlineformset_factory(Workflow, Node, form=NodeForm, max_num=0, can_order=False, can_delete=False)
  history = History.objects.filter(submitter=request.user, job=workflow).order_by('-submission_date')

  if request.method == 'POST' and Job.objects.can_edit_or_exception(request, workflow):
    try:
      workflow_form = WorkflowForm(request.POST, instance=workflow)
      actions_formset = WorkflowFormSet(request.POST, request.FILES, instance=workflow)

      if 'clone_action' in request.POST: return clone_action(request, action=request.POST['clone_action'])
      if 'delete_action' in request.POST: return delete_action(request, action=request.POST['delete_action'])
      if 'move_up_action' in request.POST: return move_up_action(request, action=request.POST['move_up_action'])
      if 'move_down_action' in request.POST: return move_down_action(request, action=request.POST['move_down_action'])

      if workflow_form.is_valid() and actions_formset.is_valid():
        workflow_form.save()
        actions_formset.save()

        if workflow.has_cycle():
          raise PopupException(_('Sorry, this operation is not creating a cycle which would break the workflow.'))

        request.info(_("Workflow saved!"))
        return redirect(reverse('oozie:edit_workflow', kwargs={'workflow': workflow.id}))
    except Exception, e:
      request.error(_('Sorry, this operation is not supported: %(error)s') % {'error': e})
Example #2
0
def edit_workflow(request, workflow):
    WorkflowFormSet = inlineformset_factory(Workflow,
                                            Node,
                                            form=NodeForm,
                                            max_num=0,
                                            can_order=False,
                                            can_delete=False)
    history = History.objects.filter(submitter=request.user,
                                     job=workflow).order_by('-submission_date')

    if request.method == 'POST' and Job.objects.can_edit_or_exception(
            request, workflow):
        try:
            workflow_form = WorkflowForm(request.POST, instance=workflow)
            actions_formset = WorkflowFormSet(request.POST,
                                              request.FILES,
                                              instance=workflow)

            if 'clone_action' in request.POST:
                return clone_action(request,
                                    action=request.POST['clone_action'])
            if 'delete_action' in request.POST:
                return delete_action(request,
                                     action=request.POST['delete_action'])
            if 'move_up_action' in request.POST:
                return move_up_action(request,
                                      action=request.POST['move_up_action'])
            if 'move_down_action' in request.POST:
                return move_down_action(
                    request, action=request.POST['move_down_action'])

            if workflow_form.is_valid() and actions_formset.is_valid():
                workflow = workflow_form.save()
                actions_formset.save()

                if workflow.has_cycle():
                    raise PopupException(
                        _('Sorry, this operation is not creating a cycle which would break the workflow.'
                          ))

                Workflow.objects.check_workspace(workflow, request.fs)

                request.info(_("Workflow saved!"))
                return redirect(
                    reverse('oozie:edit_workflow',
                            kwargs={'workflow': workflow.id}))
        except Exception, e:
            request.error(
                _('Sorry, this operation is not supported: %(error)s') %
                {'error': e})
Example #3
0
def create_workflow(request):
    workflow = Workflow.objects.new_workflow(request.user)

    if request.method == "POST":
        workflow_form = WorkflowForm(request.POST, instance=workflow)

        if workflow_form.is_valid():
            wf = workflow_form.save()
            Workflow.objects.initialize(wf, request.fs)
            return redirect(reverse("oozie:edit_workflow", kwargs={"workflow": workflow.id}))
        else:
            request.error(_("Errors on the form: %s") % workflow_form.errors)
    else:
        workflow_form = WorkflowForm(instance=workflow)

    return render("editor/create_workflow.mako", request, {"workflow_form": workflow_form, "workflow": workflow})
Example #4
0
def create_workflow(request):
  workflow = Workflow.objects.new_workflow(request.user)

  if request.method == 'POST':
    workflow_form = WorkflowForm(request.POST, instance=workflow)

    if workflow_form.is_valid():
      wf = workflow_form.save()
      wf.managed = True
      Workflow.objects.initialize(wf, request.fs)
      return redirect(reverse('oozie:edit_workflow', kwargs={'workflow': workflow.id}))
  else:
    workflow_form = WorkflowForm(instance=workflow)

  return render('editor/create_workflow.mako', request, {
    'workflow_form': workflow_form,
    'workflow': workflow,
  })
Example #5
0
def create_workflow(request):
  workflow = Workflow.objects.new_workflow(request.user)

  if request.method == 'POST':
    workflow_form = WorkflowForm(request.POST, instance=workflow)

    if workflow_form.is_valid():
      wf = workflow_form.save()
      wf.managed = True
      Workflow.objects.initialize(wf, request.fs)
      return redirect(reverse('oozie:edit_workflow', kwargs={'workflow': workflow.id}))
  else:
    workflow_form = WorkflowForm(instance=workflow)

  return render('editor/create_workflow.mako', request, {
    'workflow_form': workflow_form,
    'workflow': workflow,
  })