def edit_bundled_coordinator(request, bundle, bundled_coordinator):
    bundled_coordinator_instance = BundledCoordinator.objects.get(id=bundled_coordinator) # todo secu

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

    if request.method == 'POST':
        bundled_coordinator_form = BundledCoordinatorForm(request.POST, instance=bundled_coordinator_instance,
                                                          prefix='edit-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(_('Bundled coordinator updated!'))
    else:
        bundled_coordinator_form = BundledCoordinatorForm(instance=bundled_coordinator_instance,
                                                          prefix='edit-bundled-coordinator')

    if response['status'] != 0:
        response['data'] = render('editor/edit_bundled_coordinator.mako', request, {
            'bundle': bundle,
            'bundled_coordinator_form': bundled_coordinator_form,
            'bundled_coordinator_instance': bundled_coordinator_instance,
        }, force_template=True).content

    return HttpResponse(json.dumps(response), mimetype="application/json")
Exemple #2
0
def edit_bundled_coordinator(request, bundle, bundled_coordinator):
    bundled_coordinator_instance = BundledCoordinator.objects.get(id=bundled_coordinator)  # todo secu

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

    if request.method == "POST":
        bundled_coordinator_form = BundledCoordinatorForm(
            request.POST, instance=bundled_coordinator_instance, prefix="edit-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(_("Bundled coordinator updated!"))
    else:
        bundled_coordinator_form = BundledCoordinatorForm(
            instance=bundled_coordinator_instance, prefix="edit-bundled-coordinator"
        )

    if response["status"] != 0:
        response["data"] = render(
            "editor/edit_bundled_coordinator.mako",
            request,
            {
                "bundle": bundle,
                "bundled_coordinator_form": bundled_coordinator_form,
                "bundled_coordinator_instance": bundled_coordinator_instance,
            },
            force_template=True,
        ).content

    return HttpResponse(json.dumps(response), mimetype="application/json")
Exemple #3
0
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")
Exemple #4
0
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")
Exemple #5
0
def edit_bundled_coordinator(request, bundle, bundled_coordinator):
    bundled_coordinator_instance = BundledCoordinator.objects.get(
        id=bundled_coordinator)  # todo secu

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

    if request.method == 'POST':
        bundled_coordinator_form = BundledCoordinatorForm(
            request.POST,
            instance=bundled_coordinator_instance,
            prefix='edit-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(_('Bundled coordinator updated!'))
    else:
        bundled_coordinator_form = BundledCoordinatorForm(
            instance=bundled_coordinator_instance,
            prefix='edit-bundled-coordinator')

    if response['status'] != 0:
        response['data'] = render(
            'editor/edit_bundled_coordinator.mako',
            request, {
                'bundle': bundle,
                'bundled_coordinator_form': bundled_coordinator_form,
                'bundled_coordinator_instance': bundled_coordinator_instance,
            },
            force_template=True).content

    return HttpResponse(json.dumps(response), mimetype="application/json")
Exemple #6
0
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')
Exemple #7
0
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")