def create_bundled_coordinator(request, bundle): bundled_coordinator_instance = BundledCoordinator(bundle=bundle) response = {'status': -1, 'data': 'None'} if request.method == 'POST': bundled_coordinator_form = BundledCoordinatorForm( request.POST, instance=bundled_coordinator_instance, prefix='create-bundled-coordinator') if bundled_coordinator_form.is_valid(): bundled_coordinator_form.save() response['status'] = 0 response['data'] = reverse('oozie:edit_bundle', kwargs={'bundle': bundle.id }) + "#listCoordinators" request.info(_('Coordinator added to the bundle!')) else: bundled_coordinator_form = BundledCoordinatorForm( instance=bundled_coordinator_instance, prefix='create-bundled-coordinator') if response['status'] != 0: response['data'] = get_create_bundled_coordinator_html( request, bundle, bundled_coordinator_form=bundled_coordinator_form) return HttpResponse(json.dumps(response), mimetype="application/json")
def get_create_bundled_coordinator_html(request, bundle, bundled_coordinator_form=None): if bundled_coordinator_form is None: bundled_coordinator_instance = BundledCoordinator(bundle=bundle) bundled_coordinator_form = BundledCoordinatorForm(instance=bundled_coordinator_instance, prefix='create-bundled-coordinator') return render('editor/create_bundled_coordinator.mako', request, { 'bundle': bundle, 'bundled_coordinator_form': bundled_coordinator_form, }, force_template=True).content.decode('utf-8', 'replace')