当前位置: 首页>>代码示例>>Python>>正文


Python forms.WorkflowForm类代码示例

本文整理汇总了Python中oozie.forms.WorkflowForm的典型用法代码示例。如果您正苦于以下问题:Python WorkflowForm类的具体用法?Python WorkflowForm怎么用?Python WorkflowForm使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了WorkflowForm类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: edit_workflow

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})
开发者ID:DatalakeInc,项目名称:hortonworks-sandbox,代码行数:27,代码来源:editor.py

示例2: workflow_save

def workflow_save(request, workflow):
    if request.method != "POST":
        raise StructuredException(code="METHOD_NOT_ALLOWED_ERROR", message=_("Must be POST request."), error_code=405)

    json_workflow = format_dict_field_values(json.loads(request.POST.get("workflow")))
    json_workflow.setdefault("schema_version", workflow.schema_version)

    form = WorkflowForm(data=json_workflow)

    if not form.is_valid():
        raise StructuredException(
            code="INVALID_REQUEST_ERROR",
            message=_("Error saving workflow"),
            data={"errors": form.errors},
            error_code=400,
        )

    json_nodes = json_workflow["nodes"]
    id_map = {}
    errors = {}

    if not _validate_nodes_json(json_nodes, errors, request.user, workflow):
        raise StructuredException(
            code="INVALID_REQUEST_ERROR", message=_("Error saving workflow"), data={"errors": errors}, error_code=400
        )

    workflow = _update_workflow_json(json_workflow)
    nodes = _update_workflow_nodes_json(workflow, json_nodes, id_map, request.user)

    # Update links
    index = 0
    for json_node in json_nodes:
        child_links = json_node["child_links"]
        Link.objects.filter(parent=nodes[index]).delete()

        for child_link in child_links:
            link = Link()
            link.id = getattr(child_link, "id", None)
            link.name = child_link["name"]

            id = str(child_link["parent"])
            link.parent = Node.objects.get(id=id_map[id])

            id = str(child_link["child"])
            link.child = Node.objects.get(id=id_map[id])

            link.comment = child_link.get("comment", "")

            link.save()

        index += 1

    # Make sure workflow HDFS permissions are correct
    Workflow.objects.check_workspace(workflow, request.fs)

    return _workflow(request, workflow=workflow)
开发者ID:FashtimeDotCom,项目名称:hue,代码行数:56,代码来源:api.py

示例3: workflow_save

def workflow_save(request, workflow):
  if request.method != 'POST':
    raise StructuredException(code="METHOD_NOT_ALLOWED_ERROR", message=_('Must be POST request.'), error_code=405)

  json_workflow = format_dict_field_values(json.loads(str(request.POST.get('workflow'))))
  json_workflow.setdefault('schema_version', workflow.schema_version)

  form = WorkflowForm(data=json_workflow)

  if not form.is_valid():
    raise StructuredException(code="INVALID_REQUEST_ERROR", message=_('Error saving workflow'), data={'errors': form.errors}, error_code=400)

  json_nodes = json_workflow['nodes']
  id_map = {}
  errors = {}

  if not _validate_nodes_json(json_nodes, errors, request.user, workflow):
    raise StructuredException(code="INVALID_REQUEST_ERROR", message=_('Error saving workflow'), data={'errors': errors}, error_code=400)

  workflow = _update_workflow_json(json_workflow)
  nodes = _update_workflow_nodes_json(workflow, json_nodes, id_map, request.user)

  # Update links
  index = 0
  for json_node in json_nodes:
    child_links = json_node['child_links']
    Link.objects.filter(parent=nodes[index]).delete()

    for child_link in child_links:
      link = Link()
      link.id = getattr(child_link, 'id', None)
      link.name = child_link['name']

      id = str(child_link['parent'])
      link.parent = Node.objects.get(id=id_map[id])

      id = str(child_link['child'])
      link.child = Node.objects.get(id=id_map[id])

      link.comment = child_link.get('comment', '')

      link.save()

    index += 1

  # Make sure workflow HDFS permissions are correct
  Workflow.objects.check_workspace(workflow, request.fs)

  return _workflow(request, workflow=workflow)
开发者ID:bugcy013,项目名称:hue,代码行数:49,代码来源:api.py

示例4: create_workflow

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})
开发者ID:romainr,项目名称:hue,代码行数:16,代码来源:editor.py

示例5: create_workflow

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,
  })
开发者ID:18600597055,项目名称:hue,代码行数:18,代码来源:editor.py


注:本文中的oozie.forms.WorkflowForm类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。