示例#1
0
文件: editor.py 项目: 18600597055/hue
def create_coordinator(request, workflow=None):
  if workflow is not None:
    coordinator = Coordinator(owner=request.user, schema_version="uri:oozie:coordinator:0.2", workflow=workflow)
  else:
    coordinator = Coordinator(owner=request.user, schema_version="uri:oozie:coordinator:0.2")

  enable_cron_scheduling = ENABLE_CRON_SCHEDULING.get()

  if request.method == 'POST':
    coordinator_form = CoordinatorForm(request.POST, instance=coordinator, user=request.user)

    if coordinator_form.is_valid():
      coordinator = coordinator_form.save()
      if enable_cron_scheduling:
        coordinator.cron_frequency = {'frequency': request.POST.get('cron_frequency'), 'isAdvancedCron': request.POST.get('isAdvancedCron') == 'on'}
      coordinator.save()
      Document.objects.link(coordinator, owner=coordinator.owner, name=coordinator.name, description=coordinator.description)
      return redirect(reverse('oozie:edit_coordinator', kwargs={'coordinator': coordinator.id}) + "#step3")
    else:
      request.error(_('Errors on the form: %s') % coordinator_form.errors)
  else:
    coordinator_form = CoordinatorForm(instance=coordinator, user=request.user)

  return render('editor/create_coordinator.mako', request, {
    'coordinator': coordinator,
    'coordinator_form': coordinator_form,
    'coordinator_frequency': json.dumps(coordinator.cron_frequency),
    'enable_cron_scheduling': enable_cron_scheduling,
  })
示例#2
0
文件: editor.py 项目: Web5design/hue
def edit_coordinator(request, coordinator):
  history = History.objects.filter(submitter=request.user, job=coordinator).order_by('-submission_date')

  DatasetFormSet = inlineformset_factory(Coordinator, Dataset, form=DatasetForm, max_num=0, can_order=False, can_delete=True)
  DataInputFormSet = inlineformset_factory(Coordinator, DataInput, form=DataInputForm, max_num=0, can_order=False, can_delete=True)
  DataInputFormSet.form = staticmethod(curry(DataInputForm, coordinator=coordinator))
  DataOutputFormSet = inlineformset_factory(Coordinator, DataOutput, form=DataOutputForm, max_num=0, can_order=False, can_delete=True)
  DataOutputFormSet.form = staticmethod(curry(DataOutputForm, coordinator=coordinator))

  dataset = Dataset(coordinator=coordinator)
  dataset_form = DatasetForm(instance=dataset, prefix='create')

  NewDataInputFormSet = inlineformset_factory(Coordinator, DataInput, form=DataInputForm, extra=0, can_order=False, can_delete=False)
  NewDataInputFormSet.form = staticmethod(curry(DataInputForm, coordinator=coordinator))
  NewDataOutputFormSet = inlineformset_factory(Coordinator, DataOutput, form=DataOutputForm, extra=0, can_order=False, can_delete=False)
  NewDataOutputFormSet.form = staticmethod(curry(DataOutputForm, coordinator=coordinator))

  if request.method == 'POST':
    coordinator_form = CoordinatorForm(request.POST, instance=coordinator, user=request.user)
    dataset_formset = DatasetFormSet(request.POST, request.FILES, instance=coordinator)
    data_input_formset = DataInputFormSet(request.POST, request.FILES, instance=coordinator)
    data_output_formset = DataOutputFormSet(request.POST, request.FILES, instance=coordinator)
    new_data_input_formset = NewDataInputFormSet(request.POST, request.FILES, instance=coordinator, prefix='input')
    new_data_output_formset = NewDataOutputFormSet(request.POST, request.FILES, instance=coordinator, prefix='output')

    if coordinator_form.is_valid() and dataset_formset.is_valid() and data_input_formset.is_valid() and data_output_formset.is_valid() \
        and new_data_input_formset.is_valid() and new_data_output_formset.is_valid():
      coordinator = coordinator_form.save()
      dataset_formset.save()
      data_input_formset.save()
      data_output_formset.save()
      new_data_input_formset.save()
      new_data_output_formset.save()

      coordinator.sla = json.loads(request.POST.get('sla'))
      coordinator.save()

      request.info(_('Coordinator saved.'))
      return redirect(reverse('oozie:edit_coordinator', kwargs={'coordinator': coordinator.id}))
  else:
    coordinator_form = CoordinatorForm(instance=coordinator, user=request.user)
    dataset_formset = DatasetFormSet(instance=coordinator)
    data_input_formset = DataInputFormSet(instance=coordinator)
    data_output_formset = DataOutputFormSet(instance=coordinator)
    new_data_input_formset = NewDataInputFormSet(queryset=DataInput.objects.none(), instance=coordinator, prefix='input')
    new_data_output_formset = NewDataOutputFormSet(queryset=DataOutput.objects.none(), instance=coordinator, prefix='output')

  return render('editor/edit_coordinator.mako', request, {
    'coordinator': coordinator,
    'coordinator_form': coordinator_form,
    'dataset_formset': dataset_formset,
    'data_input_formset': data_input_formset,
    'data_output_formset': data_output_formset,
    'dataset': dataset,
    'dataset_form': dataset_form,
    'new_data_input_formset': new_data_input_formset,
    'new_data_output_formset': new_data_output_formset,
    'history': history
  })
示例#3
0
文件: editor.py 项目: romainr/hue
def create_coordinator(request, workflow=None):
    if workflow is not None:
        coordinator = Coordinator(owner=request.user, schema_version="uri:oozie:coordinator:0.1", workflow=workflow)
    else:
        coordinator = Coordinator(owner=request.user, schema_version="uri:oozie:coordinator:0.1")

    if request.method == "POST":
        coordinator_form = CoordinatorForm(request.POST, instance=coordinator, user=request.user)

        if coordinator_form.is_valid():
            coordinator = coordinator_form.save()
            return redirect(reverse("oozie:edit_coordinator", kwargs={"coordinator": coordinator.id}) + "#step3")
        else:
            request.error(_("Errors on the form: %s") % coordinator_form.errors)
    else:
        coordinator_form = CoordinatorForm(instance=coordinator, user=request.user)

    return render(
        "editor/create_coordinator.mako", request, {"coordinator": coordinator, "coordinator_form": coordinator_form}
    )
示例#4
0
文件: editor.py 项目: yjkim/hue
def create_coordinator(request, workflow=None):
  if workflow is not None:
    coordinator = Coordinator(owner=request.user, schema_version="uri:oozie:coordinator:0.1", workflow=workflow)
  else:
    coordinator = Coordinator(owner=request.user, schema_version="uri:oozie:coordinator:0.1")

  if request.method == 'POST':
    coordinator_form = CoordinatorForm(request.POST, instance=coordinator, user=request.user)

    if coordinator_form.is_valid():
      coordinator = coordinator_form.save()
      return redirect(reverse('oozie:edit_coordinator', kwargs={'coordinator': coordinator.id}) + "#step3")
    else:
      request.error(_('Errors on the form: %s') % coordinator_form.errors)
  else:
    coordinator_form = CoordinatorForm(instance=coordinator, user=request.user)

  return render('editor/create_coordinator.mako', request, {
    'coordinator': coordinator,
    'coordinator_form': coordinator_form,
  })
示例#5
0
文件: editor.py 项目: agibsonccc/hue
def create_coordinator(request, workflow=None):
    if workflow is not None:
        coordinator = Coordinator(owner=request.user,
                                  schema_version="uri:oozie:coordinator:0.1",
                                  workflow=workflow)
    else:
        coordinator = Coordinator(owner=request.user,
                                  schema_version="uri:oozie:coordinator:0.1")

    if request.method == 'POST':
        coordinator_form = CoordinatorForm(request.POST,
                                           instance=coordinator,
                                           user=request.user)

        if coordinator_form.is_valid():
            coordinator = coordinator_form.save()
            return redirect(
                reverse('oozie:edit_coordinator',
                        kwargs={'coordinator': coordinator.id}) + "#step3")
        else:
            request.error(
                _('Errors on the form: %s') % coordinator_form.errors)
    else:
        coordinator_form = CoordinatorForm(instance=coordinator,
                                           user=request.user)

    return render('editor/create_coordinator.mako', request, {
        'coordinator': coordinator,
        'coordinator_form': coordinator_form,
    })
示例#6
0
def create_coordinator(request, workflow=None):
  if workflow is not None:
    coordinator = Coordinator(owner=request.user, schema_version="uri:oozie:coordinator:0.2", coordinatorworkflow=workflow)
  else:
    coordinator = Coordinator(owner=request.user, schema_version="uri:oozie:coordinator:0.2")

  enable_cron_scheduling = ENABLE_CRON_SCHEDULING.get()

  if request.method == 'POST':
    coordinator_form = CoordinatorForm(request.POST, instance=coordinator, user=request.user)

    if coordinator_form.is_valid():
      coordinator = coordinator_form.save()
      if enable_cron_scheduling:
        coordinator.cron_frequency = {'frequency': request.POST.get('cron_frequency'), 'isAdvancedCron': request.POST.get('isAdvancedCron') == 'on'}
      coordinator.save()
      Document.objects.link(coordinator, owner=coordinator.owner, name=coordinator.name, description=coordinator.description)
      return redirect(reverse('oozie:edit_coordinator', kwargs={'coordinator': coordinator.id}) + "#step3")
    else:
      request.error(_('Errors on the form: %s') % coordinator_form.errors)
  else:
    coordinator_form = CoordinatorForm(instance=coordinator, user=request.user)

  return render('editor/create_coordinator.mako', request, {
    'coordinator': coordinator,
    'coordinator_form': coordinator_form,
    'coordinator_frequency': json.dumps(coordinator.cron_frequency),
    'enable_cron_scheduling': enable_cron_scheduling,
  })
示例#7
0
文件: editor.py 项目: mravi/hue
def edit_coordinator(request, coordinator):
  history = History.objects.filter(submitter=request.user, job=coordinator).order_by('-submission_date')

  DatasetFormSet = inlineformset_factory(Coordinator, Dataset, form=DatasetForm, max_num=0, can_order=False, can_delete=True)
  DataInputFormSet = inlineformset_factory(Coordinator, DataInput, form=DataInputForm, max_num=0, can_order=False, can_delete=True)
  DataInputFormSet.form = staticmethod(curry(DataInputForm, coordinator=coordinator))
  DataOutputFormSet = inlineformset_factory(Coordinator, DataOutput, form=DataOutputForm, max_num=0, can_order=False, can_delete=True)
  DataOutputFormSet.form = staticmethod(curry(DataOutputForm, coordinator=coordinator))

  dataset = Dataset(coordinator=coordinator)
  dataset_form = DatasetForm(instance=dataset, prefix='create')

  NewDataInputFormSet = inlineformset_factory(Coordinator, DataInput, form=DataInputForm, extra=0, can_order=False, can_delete=False)
  NewDataInputFormSet.form = staticmethod(curry(DataInputForm, coordinator=coordinator))
  NewDataOutputFormSet = inlineformset_factory(Coordinator, DataOutput, form=DataOutputForm, extra=0, can_order=False, can_delete=False)
  NewDataOutputFormSet.form = staticmethod(curry(DataOutputForm, coordinator=coordinator))

  if request.method == 'POST':
    coordinator_form = CoordinatorForm(request.POST, instance=coordinator, user=request.user)
    dataset_formset = DatasetFormSet(request.POST, request.FILES, instance=coordinator)
    data_input_formset = DataInputFormSet(request.POST, request.FILES, instance=coordinator)
    data_output_formset = DataOutputFormSet(request.POST, request.FILES, instance=coordinator)
    new_data_input_formset = NewDataInputFormSet(request.POST, request.FILES, instance=coordinator, prefix='input')
    new_data_output_formset = NewDataOutputFormSet(request.POST, request.FILES, instance=coordinator, prefix='output')

    if coordinator_form.is_valid() and dataset_formset.is_valid() and data_input_formset.is_valid() and data_output_formset.is_valid() \
        and new_data_input_formset.is_valid() and new_data_output_formset.is_valid():
      coordinator = coordinator_form.save()
      dataset_formset.save()
      data_input_formset.save()
      data_output_formset.save()
      new_data_input_formset.save()
      new_data_output_formset.save()

      request.info(_('Coordinator saved.'))
      return redirect(reverse('oozie:edit_coordinator', kwargs={'coordinator': coordinator.id}))
  else:
    coordinator_form = CoordinatorForm(instance=coordinator, user=request.user)
    dataset_formset = DatasetFormSet(instance=coordinator)
    data_input_formset = DataInputFormSet(instance=coordinator)
    data_output_formset = DataOutputFormSet(instance=coordinator)
    new_data_input_formset = NewDataInputFormSet(queryset=DataInput.objects.none(), instance=coordinator, prefix='input')
    new_data_output_formset = NewDataOutputFormSet(queryset=DataOutput.objects.none(), instance=coordinator, prefix='output')

  return render('editor/edit_coordinator.mako', request, {
    'coordinator': coordinator,
    'coordinator_form': coordinator_form,
    'dataset_formset': dataset_formset,
    'data_input_formset': data_input_formset,
    'data_output_formset': data_output_formset,
    'dataset': dataset,
    'dataset_form': dataset_form,
    'new_data_input_formset': new_data_input_formset,
    'new_data_output_formset': new_data_output_formset,
    'history': history
  })
示例#8
0
文件: editor.py 项目: weconquered/hue
def edit_coordinator(request, coordinator):
    history = History.objects.filter(
        submitter=request.user, job=coordinator).order_by('-submission_date')

    DatasetFormSet = inlineformset_factory(Coordinator,
                                           Dataset,
                                           form=DatasetForm,
                                           max_num=0,
                                           can_order=False,
                                           can_delete=True)
    DataInputFormSet = inlineformset_factory(Coordinator,
                                             DataInput,
                                             form=DataInputForm,
                                             max_num=0,
                                             can_order=False,
                                             can_delete=True)
    DataInputFormSet.form = staticmethod(
        curry(DataInputForm, coordinator=coordinator))
    DataOutputFormSet = inlineformset_factory(Coordinator,
                                              DataOutput,
                                              form=DataOutputForm,
                                              max_num=0,
                                              can_order=False,
                                              can_delete=True)
    DataOutputFormSet.form = staticmethod(
        curry(DataOutputForm, coordinator=coordinator))

    dataset = Dataset(coordinator=coordinator)
    dataset_form = DatasetForm(instance=dataset, prefix='create')

    NewDataInputFormSet = inlineformset_factory(Coordinator,
                                                DataInput,
                                                form=DataInputForm,
                                                extra=0,
                                                can_order=False,
                                                can_delete=False)
    NewDataInputFormSet.form = staticmethod(
        curry(DataInputForm, coordinator=coordinator))
    NewDataOutputFormSet = inlineformset_factory(Coordinator,
                                                 DataOutput,
                                                 form=DataOutputForm,
                                                 extra=0,
                                                 can_order=False,
                                                 can_delete=False)
    NewDataOutputFormSet.form = staticmethod(
        curry(DataOutputForm, coordinator=coordinator))

    enable_cron_scheduling = ENABLE_CRON_SCHEDULING.get()

    if request.method == 'POST':
        coordinator_form = CoordinatorForm(request.POST,
                                           instance=coordinator,
                                           user=request.user)
        dataset_formset = DatasetFormSet(request.POST,
                                         request.FILES,
                                         instance=coordinator)
        data_input_formset = DataInputFormSet(request.POST,
                                              request.FILES,
                                              instance=coordinator)
        data_output_formset = DataOutputFormSet(request.POST,
                                                request.FILES,
                                                instance=coordinator)
        new_data_input_formset = NewDataInputFormSet(request.POST,
                                                     request.FILES,
                                                     instance=coordinator,
                                                     prefix='input')
        new_data_output_formset = NewDataOutputFormSet(request.POST,
                                                       request.FILES,
                                                       instance=coordinator,
                                                       prefix='output')

        if coordinator_form.is_valid() and dataset_formset.is_valid() and data_input_formset.is_valid() and data_output_formset.is_valid() \
            and new_data_input_formset.is_valid() and new_data_output_formset.is_valid():
            coordinator = coordinator_form.save()
            dataset_formset.save()
            data_input_formset.save()
            data_output_formset.save()
            new_data_input_formset.save()
            new_data_output_formset.save()
            coordinator.sla = json.loads(request.POST.get('sla'))
            if enable_cron_scheduling:
                coordinator.cron_frequency = {
                    'frequency': request.POST.get('cron_frequency'),
                    'isAdvancedCron':
                    request.POST.get('isAdvancedCron') == 'on'
                }
            coordinator.save()

            request.info(_('Coordinator saved.'))
            return redirect(
                reverse('oozie:edit_coordinator',
                        kwargs={'coordinator': coordinator.id}))
    else:
        coordinator_form = CoordinatorForm(instance=coordinator,
                                           user=request.user)
        dataset_formset = DatasetFormSet(instance=coordinator)
        data_input_formset = DataInputFormSet(instance=coordinator)
        data_output_formset = DataOutputFormSet(instance=coordinator)
        new_data_input_formset = NewDataInputFormSet(
            queryset=DataInput.objects.none(),
            instance=coordinator,
            prefix='input')
        new_data_output_formset = NewDataOutputFormSet(
            queryset=DataOutput.objects.none(),
            instance=coordinator,
            prefix='output')

    return render(
        'editor/edit_coordinator.mako', request, {
            'coordinator': coordinator,
            'coordinator_form': coordinator_form,
            'dataset_formset': dataset_formset,
            'data_input_formset': data_input_formset,
            'data_output_formset': data_output_formset,
            'dataset': dataset,
            'dataset_form': dataset_form,
            'new_data_input_formset': new_data_input_formset,
            'new_data_output_formset': new_data_output_formset,
            'history': history,
            'coordinator_frequency': json.dumps(coordinator.cron_frequency),
            'enable_cron_scheduling': enable_cron_scheduling,
        })
示例#9
0
文件: editor.py 项目: romainr/hue
def edit_coordinator(request, coordinator):
    history = History.objects.filter(submitter=request.user, job=coordinator).order_by("-submission_date")

    DatasetFormSet = inlineformset_factory(
        Coordinator, Dataset, form=DatasetForm, max_num=0, can_order=False, can_delete=True
    )
    DataInputFormSet = inlineformset_factory(
        Coordinator, DataInput, form=DataInputForm, max_num=0, can_order=False, can_delete=True
    )
    DataInputFormSet.form = staticmethod(curry(DataInputForm, coordinator=coordinator))
    DataOutputFormSet = inlineformset_factory(
        Coordinator, DataOutput, form=DataOutputForm, max_num=0, can_order=False, can_delete=True
    )
    DataOutputFormSet.form = staticmethod(curry(DataOutputForm, coordinator=coordinator))

    dataset = Dataset(coordinator=coordinator)
    dataset_form = DatasetForm(instance=dataset, prefix="create")

    NewDataInputFormSet = inlineformset_factory(
        Coordinator, DataInput, form=DataInputForm, extra=0, can_order=False, can_delete=False
    )
    NewDataInputFormSet.form = staticmethod(curry(DataInputForm, coordinator=coordinator))
    NewDataOutputFormSet = inlineformset_factory(
        Coordinator, DataOutput, form=DataOutputForm, extra=0, can_order=False, can_delete=False
    )
    NewDataOutputFormSet.form = staticmethod(curry(DataOutputForm, coordinator=coordinator))

    if request.method == "POST":
        coordinator_form = CoordinatorForm(request.POST, instance=coordinator, user=request.user)
        dataset_formset = DatasetFormSet(request.POST, request.FILES, instance=coordinator)
        data_input_formset = DataInputFormSet(request.POST, request.FILES, instance=coordinator)
        data_output_formset = DataOutputFormSet(request.POST, request.FILES, instance=coordinator)
        new_data_input_formset = NewDataInputFormSet(request.POST, request.FILES, instance=coordinator, prefix="input")
        new_data_output_formset = NewDataOutputFormSet(
            request.POST, request.FILES, instance=coordinator, prefix="output"
        )

        if (
            coordinator_form.is_valid()
            and dataset_formset.is_valid()
            and data_input_formset.is_valid()
            and data_output_formset.is_valid()
            and new_data_input_formset.is_valid()
            and new_data_output_formset.is_valid()
        ):
            coordinator = coordinator_form.save()
            dataset_formset.save()
            data_input_formset.save()
            data_output_formset.save()
            new_data_input_formset.save()
            new_data_output_formset.save()

            request.info(_("Coordinator saved."))
            return redirect(reverse("oozie:edit_coordinator", kwargs={"coordinator": coordinator.id}))
    else:
        coordinator_form = CoordinatorForm(instance=coordinator, user=request.user)
        dataset_formset = DatasetFormSet(instance=coordinator)
        data_input_formset = DataInputFormSet(instance=coordinator)
        data_output_formset = DataOutputFormSet(instance=coordinator)
        new_data_input_formset = NewDataInputFormSet(
            queryset=DataInput.objects.none(), instance=coordinator, prefix="input"
        )
        new_data_output_formset = NewDataOutputFormSet(
            queryset=DataOutput.objects.none(), instance=coordinator, prefix="output"
        )

    return render(
        "editor/edit_coordinator.mako",
        request,
        {
            "coordinator": coordinator,
            "coordinator_form": coordinator_form,
            "dataset_formset": dataset_formset,
            "data_input_formset": data_input_formset,
            "data_output_formset": data_output_formset,
            "dataset": dataset,
            "dataset_form": dataset_form,
            "new_data_input_formset": new_data_input_formset,
            "new_data_output_formset": new_data_output_formset,
            "history": history,
        },
    )