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


Python DatasetForm.is_valid方法代码示例

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


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

示例1: edit_coordinator_dataset

# 需要导入模块: from oozie.forms import DatasetForm [as 别名]
# 或者: from oozie.forms.DatasetForm import is_valid [as 别名]
def edit_coordinator_dataset(request, dataset):
  """Returns HTML for modal to edit datasets"""

  response = {'status': -1, 'data': 'None'}

  if request.method == 'POST':
    dataset_form = DatasetForm(request.POST, instance=dataset, prefix='edit')

    if dataset_form.is_valid():
      dataset = dataset_form.save()
      response['status'] = 0
      response['data'] = reverse('oozie:edit_coordinator', kwargs={'coordinator': dataset.coordinator.id}) + "#listDataset"
      request.info(_('Dataset modified'))
      if dataset.start > dataset.coordinator.start:
        request.error(_('Beware: dataset start date was after the coordinator start date.'))
    else:
      response['data'] = dataset_form.errors
  else:
    dataset_form = DatasetForm(instance=dataset, prefix='edit')

  if response['status'] != 0:
    response['data'] = render('editor/edit_coordinator_dataset.mako', request, {
                          'coordinator': dataset.coordinator,
                          'dataset_form': dataset_form,
                          'dataset': dataset,
                          'path': request.path,
                        }, force_template=True).content

  return HttpResponse(json.dumps(response), mimetype="application/json")
开发者ID:yjkim,项目名称:hue,代码行数:31,代码来源:editor.py

示例2: create_coordinator_dataset

# 需要导入模块: from oozie.forms import DatasetForm [as 别名]
# 或者: from oozie.forms.DatasetForm import is_valid [as 别名]
def create_coordinator_dataset(request, coordinator):
  """Returns {'status' 0/1, data:html or url}"""

  dataset = Dataset(coordinator=coordinator)
  response = {'status': -1, 'data': 'None'}

  if request.method == 'POST':
    dataset_form = DatasetForm(request.POST, instance=dataset, prefix='create')

    if dataset_form.is_valid():
      dataset_form.save()
      response['status'] = 0
      response['data'] = reverse('oozie:edit_coordinator', kwargs={'coordinator': coordinator.id}) + "#listDataset"
      request.info(_('Dataset created'))
  else:
    ## Bad
    response['data'] = _('A POST request is required.')

  if response['status'] != 0:
    response['data'] = render('editor/create_coordinator_dataset.mako', request, {
                            'coordinator': coordinator,
                            'dataset_form': dataset_form,
                            'dataset': dataset,
                          }, force_template=True).content

  return HttpResponse(json.dumps(response), mimetype="application/json")
开发者ID:yjkim,项目名称:hue,代码行数:28,代码来源:editor.py

示例3: create_coordinator_dataset

# 需要导入模块: from oozie.forms import DatasetForm [as 别名]
# 或者: from oozie.forms.DatasetForm import is_valid [as 别名]
def create_coordinator_dataset(request, coordinator):
    """Returns {'status' 0/1, data:html or url}"""

    dataset = Dataset(coordinator=coordinator)
    response = {"status": -1, "data": "None"}

    if request.method == "POST":
        dataset_form = DatasetForm(request.POST, instance=dataset, prefix="create")

        if dataset_form.is_valid():
            dataset_form.save()
            response["status"] = 0
            response["data"] = (
                reverse("oozie:edit_coordinator", kwargs={"coordinator": coordinator.id}) + "#listDataset"
            )
            request.info(_("Dataset created"))
    else:
        ## Bad
        response["data"] = _("A POST request is required.")

    if response["status"] != 0:
        response["data"] = render(
            "editor/create_coordinator_dataset.mako",
            request,
            {"coordinator": coordinator, "dataset_form": dataset_form, "dataset": dataset},
            force_template=True,
        ).content

    return HttpResponse(json.dumps(response), mimetype="application/json")
开发者ID:romainr,项目名称:hue,代码行数:31,代码来源:editor.py

示例4: edit_coordinator_dataset

# 需要导入模块: from oozie.forms import DatasetForm [as 别名]
# 或者: from oozie.forms.DatasetForm import is_valid [as 别名]
def edit_coordinator_dataset(request, dataset):
  """Returns HTML for modal to edit datasets"""

  if request.method == 'POST':
    dataset_form = DatasetForm(request.POST, instance=dataset)

    if dataset_form.is_valid():
      dataset_form.save()
      request.info(_('Dataset modified'));
      return redirect(reverse('oozie:edit_coordinator', kwargs={'coordinator': dataset.coordinator.id}))
    else:
      dataset_form = DatasetForm(request.POST, instance=dataset)
  else:
    dataset_form = DatasetForm(instance=dataset)

  return render('editor/edit_coordinator_dataset.mako', request, {
    'coordinator': dataset.coordinator,
    'dataset_form': dataset_form,
    'path': request.path,
  }, force_template=True)
开发者ID:ahonko,项目名称:hue,代码行数:22,代码来源:editor.py

示例5: edit_coordinator_dataset

# 需要导入模块: from oozie.forms import DatasetForm [as 别名]
# 或者: from oozie.forms.DatasetForm import is_valid [as 别名]
def edit_coordinator_dataset(request, dataset):
    """Returns HTML for modal to edit datasets"""

    if request.method == "POST":
        dataset_form = DatasetForm(request.POST, instance=dataset)

        if dataset_form.is_valid():
            dataset_form.save()
            request.info(_("Dataset modified"))
            return redirect(reverse("oozie:edit_coordinator", kwargs={"coordinator": dataset.coordinator.id}))
        else:
            dataset_form = DatasetForm(request.POST, instance=dataset)
    else:
        dataset_form = DatasetForm(instance=dataset)

    return render(
        "editor/edit_coordinator_dataset.mako",
        request,
        {"coordinator": dataset.coordinator, "dataset_form": dataset_form, "path": request.path},
        force_template=True,
    )
开发者ID:fty650660,项目名称:hue,代码行数:23,代码来源:editor.py

示例6: edit_coordinator_dataset

# 需要导入模块: from oozie.forms import DatasetForm [as 别名]
# 或者: from oozie.forms.DatasetForm import is_valid [as 别名]
def edit_coordinator_dataset(request, dataset):
    """Returns HTML for modal to edit datasets"""

    response = {"status": -1, "data": "None"}

    if request.method == "POST":
        dataset_form = DatasetForm(request.POST, instance=dataset, prefix="edit")

        if dataset_form.is_valid():
            dataset = dataset_form.save()
            response["status"] = 0
            response["data"] = (
                reverse("oozie:edit_coordinator", kwargs={"coordinator": dataset.coordinator.id}) + "#listDataset"
            )
            request.info(_("Dataset modified"))
            if dataset.start > dataset.coordinator.start:
                request.error(_("Beware: dataset start date was after the coordinator start date."))
        else:
            response["data"] = dataset_form.errors
    else:
        dataset_form = DatasetForm(instance=dataset, prefix="edit")

    if response["status"] != 0:
        response["data"] = render(
            "editor/edit_coordinator_dataset.mako",
            request,
            {
                "coordinator": dataset.coordinator,
                "dataset_form": dataset_form,
                "dataset": dataset,
                "path": request.path,
            },
            force_template=True,
        ).content

    return HttpResponse(json.dumps(response), mimetype="application/json")
开发者ID:romainr,项目名称:hue,代码行数:38,代码来源:editor.py


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