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


Python CoordinatorForm.save方法代码示例

本文整理汇总了Python中oozie.forms.CoordinatorForm.save方法的典型用法代码示例。如果您正苦于以下问题:Python CoordinatorForm.save方法的具体用法?Python CoordinatorForm.save怎么用?Python CoordinatorForm.save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在oozie.forms.CoordinatorForm的用法示例。


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

示例1: create_coordinator

# 需要导入模块: from oozie.forms import CoordinatorForm [as 别名]
# 或者: from oozie.forms.CoordinatorForm import save [as 别名]
def create_coordinator(request, workflow=None):
  if workflow is not None:
    coordinator = Coordinator(owner=request.user, schema_version="uri:oozie:coordinator:0.2", workflow=workflow)
  else:
    coordinator = Coordinator(owner=request.user, schema_version="uri:oozie:coordinator:0.2")

  enable_cron_scheduling = ENABLE_CRON_SCHEDULING.get()

  if request.method == 'POST':
    coordinator_form = CoordinatorForm(request.POST, instance=coordinator, user=request.user)

    if coordinator_form.is_valid():
      coordinator = coordinator_form.save()
      if enable_cron_scheduling:
        coordinator.cron_frequency = {'frequency': request.POST.get('cron_frequency'), 'isAdvancedCron': request.POST.get('isAdvancedCron') == 'on'}
      coordinator.save()
      Document.objects.link(coordinator, owner=coordinator.owner, name=coordinator.name, description=coordinator.description)
      return redirect(reverse('oozie:edit_coordinator', kwargs={'coordinator': coordinator.id}) + "#step3")
    else:
      request.error(_('Errors on the form: %s') % coordinator_form.errors)
  else:
    coordinator_form = CoordinatorForm(instance=coordinator, user=request.user)

  return render('editor/create_coordinator.mako', request, {
    'coordinator': coordinator,
    'coordinator_form': coordinator_form,
    'coordinator_frequency': json.dumps(coordinator.cron_frequency),
    'enable_cron_scheduling': enable_cron_scheduling,
  })
开发者ID:18600597055,项目名称:hue,代码行数:31,代码来源:editor.py

示例2: edit_coordinator

# 需要导入模块: from oozie.forms import CoordinatorForm [as 别名]
# 或者: from oozie.forms.CoordinatorForm import save [as 别名]
def edit_coordinator(request, coordinator):
  history = History.objects.filter(submitter=request.user, job=coordinator).order_by('-submission_date')

  DatasetFormSet = inlineformset_factory(Coordinator, Dataset, form=DatasetForm, max_num=0, can_order=False, can_delete=True)
  DataInputFormSet = inlineformset_factory(Coordinator, DataInput, form=DataInputForm, max_num=0, can_order=False, can_delete=True)
  DataInputFormSet.form = staticmethod(curry(DataInputForm, coordinator=coordinator))
  DataOutputFormSet = inlineformset_factory(Coordinator, DataOutput, form=DataOutputForm, max_num=0, can_order=False, can_delete=True)
  DataOutputFormSet.form = staticmethod(curry(DataOutputForm, coordinator=coordinator))

  dataset = Dataset(coordinator=coordinator)
  dataset_form = DatasetForm(instance=dataset, prefix='create')

  NewDataInputFormSet = inlineformset_factory(Coordinator, DataInput, form=DataInputForm, extra=0, can_order=False, can_delete=False)
  NewDataInputFormSet.form = staticmethod(curry(DataInputForm, coordinator=coordinator))
  NewDataOutputFormSet = inlineformset_factory(Coordinator, DataOutput, form=DataOutputForm, extra=0, can_order=False, can_delete=False)
  NewDataOutputFormSet.form = staticmethod(curry(DataOutputForm, coordinator=coordinator))

  if request.method == 'POST':
    coordinator_form = CoordinatorForm(request.POST, instance=coordinator, user=request.user)
    dataset_formset = DatasetFormSet(request.POST, request.FILES, instance=coordinator)
    data_input_formset = DataInputFormSet(request.POST, request.FILES, instance=coordinator)
    data_output_formset = DataOutputFormSet(request.POST, request.FILES, instance=coordinator)
    new_data_input_formset = NewDataInputFormSet(request.POST, request.FILES, instance=coordinator, prefix='input')
    new_data_output_formset = NewDataOutputFormSet(request.POST, request.FILES, instance=coordinator, prefix='output')

    if coordinator_form.is_valid() and dataset_formset.is_valid() and data_input_formset.is_valid() and data_output_formset.is_valid() \
        and new_data_input_formset.is_valid() and new_data_output_formset.is_valid():
      coordinator = coordinator_form.save()
      dataset_formset.save()
      data_input_formset.save()
      data_output_formset.save()
      new_data_input_formset.save()
      new_data_output_formset.save()

      coordinator.sla = json.loads(request.POST.get('sla'))
      coordinator.save()

      request.info(_('Coordinator saved.'))
      return redirect(reverse('oozie:edit_coordinator', kwargs={'coordinator': coordinator.id}))
  else:
    coordinator_form = CoordinatorForm(instance=coordinator, user=request.user)
    dataset_formset = DatasetFormSet(instance=coordinator)
    data_input_formset = DataInputFormSet(instance=coordinator)
    data_output_formset = DataOutputFormSet(instance=coordinator)
    new_data_input_formset = NewDataInputFormSet(queryset=DataInput.objects.none(), instance=coordinator, prefix='input')
    new_data_output_formset = NewDataOutputFormSet(queryset=DataOutput.objects.none(), instance=coordinator, prefix='output')

  return render('editor/edit_coordinator.mako', request, {
    'coordinator': coordinator,
    'coordinator_form': coordinator_form,
    'dataset_formset': dataset_formset,
    'data_input_formset': data_input_formset,
    'data_output_formset': data_output_formset,
    'dataset': dataset,
    'dataset_form': dataset_form,
    'new_data_input_formset': new_data_input_formset,
    'new_data_output_formset': new_data_output_formset,
    'history': history
  })
开发者ID:Web5design,项目名称:hue,代码行数:61,代码来源:editor.py

示例3: create_coordinator

# 需要导入模块: from oozie.forms import CoordinatorForm [as 别名]
# 或者: from oozie.forms.CoordinatorForm import save [as 别名]
def create_coordinator(request, workflow=None):
    if workflow is not None:
        coordinator = Coordinator(owner=request.user, schema_version="uri:oozie:coordinator:0.1", workflow=workflow)
    else:
        coordinator = Coordinator(owner=request.user, schema_version="uri:oozie:coordinator:0.1")

    if request.method == "POST":
        coordinator_form = CoordinatorForm(request.POST, instance=coordinator, user=request.user)

        if coordinator_form.is_valid():
            coordinator = coordinator_form.save()
            return redirect(reverse("oozie:edit_coordinator", kwargs={"coordinator": coordinator.id}) + "#step3")
        else:
            request.error(_("Errors on the form: %s") % coordinator_form.errors)
    else:
        coordinator_form = CoordinatorForm(instance=coordinator, user=request.user)

    return render(
        "editor/create_coordinator.mako", request, {"coordinator": coordinator, "coordinator_form": coordinator_form}
    )
开发者ID:romainr,项目名称:hue,代码行数:22,代码来源:editor.py

示例4: create_coordinator

# 需要导入模块: from oozie.forms import CoordinatorForm [as 别名]
# 或者: from oozie.forms.CoordinatorForm import save [as 别名]
def create_coordinator(request, workflow=None):
  if workflow is not None:
    coordinator = Coordinator(owner=request.user, schema_version="uri:oozie:coordinator:0.1", workflow=workflow)
  else:
    coordinator = Coordinator(owner=request.user, schema_version="uri:oozie:coordinator:0.1")

  if request.method == 'POST':
    coordinator_form = CoordinatorForm(request.POST, instance=coordinator, user=request.user)

    if coordinator_form.is_valid():
      coordinator = coordinator_form.save()
      return redirect(reverse('oozie:edit_coordinator', kwargs={'coordinator': coordinator.id}) + "#step3")
    else:
      request.error(_('Errors on the form: %s') % coordinator_form.errors)
  else:
    coordinator_form = CoordinatorForm(instance=coordinator, user=request.user)

  return render('editor/create_coordinator.mako', request, {
    'coordinator': coordinator,
    'coordinator_form': coordinator_form,
  })
开发者ID:yjkim,项目名称:hue,代码行数:23,代码来源:editor.py

示例5: edit_coordinator

# 需要导入模块: from oozie.forms import CoordinatorForm [as 别名]
# 或者: from oozie.forms.CoordinatorForm import save [as 别名]
def edit_coordinator(request, coordinator):
    history = History.objects.filter(submitter=request.user, job=coordinator).order_by("-submission_date")

    DatasetFormSet = inlineformset_factory(
        Coordinator, Dataset, form=DatasetForm, max_num=0, can_order=False, can_delete=True
    )
    DataInputFormSet = inlineformset_factory(
        Coordinator, DataInput, form=DataInputForm, max_num=0, can_order=False, can_delete=True
    )
    DataInputFormSet.form = staticmethod(curry(DataInputForm, coordinator=coordinator))
    DataOutputFormSet = inlineformset_factory(
        Coordinator, DataOutput, form=DataOutputForm, max_num=0, can_order=False, can_delete=True
    )
    DataOutputFormSet.form = staticmethod(curry(DataOutputForm, coordinator=coordinator))

    dataset = Dataset(coordinator=coordinator)
    dataset_form = DatasetForm(instance=dataset, prefix="create")

    NewDataInputFormSet = inlineformset_factory(
        Coordinator, DataInput, form=DataInputForm, extra=0, can_order=False, can_delete=False
    )
    NewDataInputFormSet.form = staticmethod(curry(DataInputForm, coordinator=coordinator))
    NewDataOutputFormSet = inlineformset_factory(
        Coordinator, DataOutput, form=DataOutputForm, extra=0, can_order=False, can_delete=False
    )
    NewDataOutputFormSet.form = staticmethod(curry(DataOutputForm, coordinator=coordinator))

    if request.method == "POST":
        coordinator_form = CoordinatorForm(request.POST, instance=coordinator, user=request.user)
        dataset_formset = DatasetFormSet(request.POST, request.FILES, instance=coordinator)
        data_input_formset = DataInputFormSet(request.POST, request.FILES, instance=coordinator)
        data_output_formset = DataOutputFormSet(request.POST, request.FILES, instance=coordinator)
        new_data_input_formset = NewDataInputFormSet(request.POST, request.FILES, instance=coordinator, prefix="input")
        new_data_output_formset = NewDataOutputFormSet(
            request.POST, request.FILES, instance=coordinator, prefix="output"
        )

        if (
            coordinator_form.is_valid()
            and dataset_formset.is_valid()
            and data_input_formset.is_valid()
            and data_output_formset.is_valid()
            and new_data_input_formset.is_valid()
            and new_data_output_formset.is_valid()
        ):
            coordinator = coordinator_form.save()
            dataset_formset.save()
            data_input_formset.save()
            data_output_formset.save()
            new_data_input_formset.save()
            new_data_output_formset.save()

            request.info(_("Coordinator saved."))
            return redirect(reverse("oozie:edit_coordinator", kwargs={"coordinator": coordinator.id}))
    else:
        coordinator_form = CoordinatorForm(instance=coordinator, user=request.user)
        dataset_formset = DatasetFormSet(instance=coordinator)
        data_input_formset = DataInputFormSet(instance=coordinator)
        data_output_formset = DataOutputFormSet(instance=coordinator)
        new_data_input_formset = NewDataInputFormSet(
            queryset=DataInput.objects.none(), instance=coordinator, prefix="input"
        )
        new_data_output_formset = NewDataOutputFormSet(
            queryset=DataOutput.objects.none(), instance=coordinator, prefix="output"
        )

    return render(
        "editor/edit_coordinator.mako",
        request,
        {
            "coordinator": coordinator,
            "coordinator_form": coordinator_form,
            "dataset_formset": dataset_formset,
            "data_input_formset": data_input_formset,
            "data_output_formset": data_output_formset,
            "dataset": dataset,
            "dataset_form": dataset_form,
            "new_data_input_formset": new_data_input_formset,
            "new_data_output_formset": new_data_output_formset,
            "history": history,
        },
    )
开发者ID:romainr,项目名称:hue,代码行数:84,代码来源:editor.py


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