Exemple #1
0
def form(request):
    if 'script_id' in request.POST.keys(): 
        script_id = request.POST['script_id']
        params = get_params_def(script_id)
        
        class_name = generator.create_class_if_needed(params, script_id, settings.DEBUG)
        form = generator.get_form_class(class_name)()
        return render_to_response(
            'parts/generator/form.html',
            {'script_form': form},
            context_instance = RequestContext(request)
        )
    else:
        return HttpResponse('no generator selected')
Exemple #2
0
def generate(request):
    if request.method == 'POST': # If the form has been submitted...
        script_id = request.POST['script_id']
        class_name = generator.get_class_name(script_id)
        form = generator.get_form_class(class_name)(request.POST)
        if form.is_valid(): # All validation rules pass 
            config, script_id = script_config_from_form(form.cleaned_data)
            return send_zipfile(script_id,config)
        else:
            return render_to_response(
                'parts/generator/index.html',
                {'script_form': form,
                 'script_id' : script_id,
                 'scripts_list': AVAIL_SCRIPTS,
                 'debugging' : settings.DEBUG},
                context_instance = RequestContext(request)
            )
    else:
        return HttpResponse('no form posted')