def script_add(request): if request.method == "GET": return render(request,"jobs/script_add.html") elif request.method == "POST": print "request POST===>",request.POST script_name = request.POST.get("script_name") if models.Script.objects.filter(scriptname=script_name): return render(request, "jobs/script_add.html", { "script_fail": "Error.Already exists the same script name!" }) else: scription_description = request.POST.get("script_description") script_type = request.POST.get("script_type") script_content = request.POST.get("script_content_shell") script_stored_path = utils.save_script_content_v2(script_name,script_type,script_content) script_generator = utils.ScriptGen(request,script_stored_path["abs_path"],script_stored_path["rel_path"]) res = script_generator.create() return render(request,"jobs/script_add.html",{ "script_success":"Successful!" })
script_name_withSuffix) return render(request, "jobs/script_edit.html", { "script": script_obj, "script_content": script_content }) elif request.method == "POST": script_name = request.POST.get("script_name") script_type = request.POST.get("script_type") script_content = request.POST.get("script_content_shell") print "update script_name===>", script_name print "update script_type===>", script_type print "update script_content==>", script_content script_stored_path = utils.save_script_content_v2( script_name, script_type, script_content) script_updater = utils.ScriptGen(request, script_stored_path["abs_path"], script_stored_path["rel_path"]) res = script_updater.update(script_id) return render(request, "jobs/script_edit.html", {"script_success": "Successful!"}) @login_required def script_authorized(request): selected_scripts = request.POST.getlist("selected_scripts[]") all_users = list(hosts_models.UserProfile.objects.all().values_list( "id", flat=True)) all_users.remove(request.user.id) print "===>all users", all_users result_list = [] for selected_script in selected_scripts: