本文整理汇总了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")
示例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")
示例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")
示例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)
示例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,
)
示例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")