本文整理汇总了Python中oozie.forms.DatasetForm类的典型用法代码示例。如果您正苦于以下问题:Python DatasetForm类的具体用法?Python DatasetForm怎么用?Python DatasetForm使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DatasetForm类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: edit_coordinator_dataset
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
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
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
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")
示例5: edit_coordinator_dataset
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
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,
)