Пример #1
0
def run(request, script_id):
    """ Execute utility script
    """
    try:
        utility = Utility.objects.get(pk=script_id)
    except:
        raise Http404

    last_runs = Results.objects.filter(utility=utility).order_by('-run_date')
    if last_runs and last_runs[0].parameters:
        parameter_string = last_runs[0].parameters
    else:
        parameter_string = Parameter.objects.get_param_string(utility)

    if request.method == 'POST':
        form = UtilityDetailForm(request.POST, instance=utility)
        parameters = ParameterStringForm(request.POST)
        if form.is_valid():
            return StreamingHttpResponse(execute(utility, form, parameters))
        else:
            return HttpResponse('Error Processing Form.')
    else:
        form = UtilityDetailForm(instance=utility)
        parameters = ParameterStringForm(initial={'parameter_string': parameter_string})

    return render_to_response('run.html',
                              {'utility': utility,
                               'form': form,
                               'parameters': parameters},
                              context_instance=RequestContext(request))
Пример #2
0
def detail(request, script_id):
    """ Return details about specific script
    """
    ParameterFormSet = get_utility_formset()

    try:
        utility = Utility.objects.get(pk=script_id)
    except:
        raise Http404

    if request.method == 'POST':
        form = UtilityDetailForm(request.POST, instance=utility)
        formset = ParameterFormSet(request.POST, instance=utility)
        if form.is_valid() and formset.is_valid():
            form.save()
            formset.save()
            return HttpResponseRedirect(request.META['HTTP_REFERER'])
    else:
        form = UtilityDetailForm(instance=utility)
        formset = ParameterFormSet(instance=utility)

    return render_to_response('detail.html',
                              {'utility': utility,
                               'form': form,
                               'formset': formset},
                              context_instance=RequestContext(request))
Пример #3
0
def detail(request, script_id):
    """ Return details about specific script
    """
    ParameterFormSet = get_utility_formset()

    try:
        utility = Utility.objects.get(pk=script_id)
    except:
        raise Http404

    if request.method == 'POST':
        form = UtilityDetailForm(request.POST, instance=utility)
        formset = ParameterFormSet(request.POST, instance=utility)
        if form.is_valid() and formset.is_valid():
            form.save()
            formset.save()
            return HttpResponseRedirect(request.META['HTTP_REFERER'])
    else:
        form = UtilityDetailForm(instance=utility)
        formset = ParameterFormSet(instance=utility)

    return render_to_response('detail.html', {
        'utility': utility,
        'form': form,
        'formset': formset
    },
                              context_instance=RequestContext(request))