def import_form(request): if request.method == "POST": json_file = request.FILES['file'] json_string = json_file.read() json_data = json.loads(json_string) template_options = json_data["template"] form_options = json_data["form"] template = ConfigTemplate() template.name = template_options["name"] template.description = template_options["description"] template.action_provider = template_options["action_provider"] template.action_provider_options = template_options["action_provider_options"] template.type = template_options["type"] template.template = unquote(template_options["template"]) template.save() input_form = InputForm() input_form.name = form_options["name"] input_form.description = form_options["description"] input_form.instuctions = form_options["instructions"] input_form.json = unquote(form_options["json"]) input_form.script = template input_form.save() return HttpResponseRedirect("/input_forms") else: form = ImportForm() context = {'form': form } return render(request, 'input_forms/import.html', context)
def import_form(request): logger.info("__ input_forms import_form __") if request.method == "POST": json_file = request.FILES['file'] json_string = json_file.read() json_data = json.loads(json_string) template_options = json_data["template"] form_options = json_data["form"] template = ConfigTemplate() template.name = template_options["name"] template.description = template_options["description"] template.action_provider = template_options["action_provider"] template.action_provider_options = template_options["action_provider_options"] template.type = template_options["type"] template.template = unquote(template_options["template"]) template.save() input_form = InputForm() input_form.name = form_options["name"] input_form.description = form_options["description"] input_form.instuctions = form_options["instructions"] input_form.json = unquote(form_options["json"]) input_form.script = template input_form.save() return HttpResponseRedirect("/input_forms") else: form = ImportForm() context = {'form': form } return render(request, 'input_forms/import.html', context)