def getRegressionForm(request, cid): """ Retrieves the regression form. Meant to be called via ajax request for possibly multiple planned executions. """ # Get the parameters case = Case.objects.get(id=cid) data = handleAjaxRequestJSONData(request) form_id = data.get('form_id', 'regression_pe_form') # Check to see if there are planned exec ids in the POST data, this means # that we are editing regression options instead of first time creation if 'pe' in data: # If there is only one delete_select_####=on, then this is a single edit if len(data['pe'].split('&')) == 1: peid = int(data['pe'].split('=')[0].split('_')[-1]) testplan = Planned_Exec.objects.get(id=peid) form = RegressionForm(case, **{'instance': testplan}) # kwargs-y # Multiples, can't assume previously chosen params else: form = RegressionForm(case) # No command line args edit, this is a new planned execution else: form = RegressionForm(case) objContext = RequestContext(request, {'regform': form, 'form_id': form_id, 'case': case}) return render_to_response('forms/pe_regression_form.html', objContext)
def editTestListPlan_ajax(request): """ POST from case detail page to change the planned_for attr for one or many planned executions. """ data = handleAjaxRequestJSONData(request) pids = data.get('pids', None) planfield = data.get('planform',None) if pids is None or planfield is None: return JSONHttpResponse({'msg': 'No planned executions or no "planned for" option were sent to the server'}, status=400) # Loop through them (same code if there is only one planned execution sent) try: for pid in pids: pidInt = int(pid.split('=')[0].split('_')[-1]) # convert "delete_select_##" to ## integer pe = Planned_Exec.objects.get(id=pidInt) if planfield: pe.planned_for = ProjectSchedule.objects.get(id=planfield['planned_for']) else: raise Exception() pe.save() except: return JSONHttpResponse({'msg': 'An unexpected error occurred while attempting to edit the planned for option.'}, status=500) return JSONHttpResponse({'msg':"Successfully edited the planned options.", 'success':True})
def editTestListCommandLineOptions_ajax(request): """ POST from case detail page to change the command line options for one or many planned executions. The data being sent from the server does not include information about browsers, plm, or test/case since multiple planned """ data = handleAjaxRequestJSONData(request) pids = data.get('pids', None) clpfields = data.get('clpform',None) if pids is None or clpfields is None: return JSONHttpResponse({'msg': 'No planned executions or no command line parameters were sent to the server'}, status=400) # Loop through them (same code if there is only one planned execution sent) try: for pid in pids: pidInt = int(pid.split('=')[0].split('_')[-1]) # convert "delete_select_##" to ## integer pe = Planned_Exec.objects.get(id=pidInt) getOrCreateCommandLineArgsFromPlannedExecution(request.user.username, pe, clpfields) except Exception as e: return JSONHttpResponse({'msg': 'An unexpected error occurred while attempting to edit the command line parameters. Error was: %s' % e.message}, status=500) return JSONHttpResponse({'msg':"Successfully edited the command line parameters.",'success':True})
def editTestListRegressionOptions_ajax(request): """ POST from case detail page to change the regression options for one or many planned executions """ data = handleAjaxRequestJSONData(request) pids = data.get('pids', None) regfields = data.get('regform',None) if pids is None or regfields is None: return JSONHttpResponse({'msg': 'No planned executions or no regression options were sent to the server'}, status=400) # Handle the regression form data if regfields is None or 'regression_enabled' not in regfields: regfields = {'regression_enabled': 'off'} if 'regression_setup' not in regfields: regfields['regression_setup'] = "off" # Loop through them (same code if there is only one planned execution sent) try: for pid in pids: pidInt = int(pid.split('=')[0].split('_')[-1]) # convert "delete_select_##" to ## integer pe = Planned_Exec.objects.get(id=pidInt) if regfields['regression_enabled'] == 'on': pe.regression = regfields['regression'] pe.test_script = regfields['test_script'] if regfields['regression_setup'] == 'on': pe.regression_setup = True else: pe.regression_setup = False else: pe.regression = REGRESSION_OPTIONS[0][0] pe.save() except: return JSONHttpResponse({'msg': 'An unexpected error occurred while attempting to edit the regression options.'}, status=500) return JSONHttpResponse({'msg':"Successfully edited the regression options.", 'success':True})
def getCommandLineArgsForm(request,cid): """Retrieves the Command Line Arguments Form""" def _createCommandLineArgsInstance(case, data): """Convenience function to create CommandLineArgs object for the form""" cmdLine = CommandLineArgs() cmdLine.case_name = case.name cmdLine.test_name = case.test.name cmdLine.external = data.get('communicator','') cmdLine.implantable = data.get('pg_model','') for key, value in CLA_BROWSER_OPTIONS: if key == data.get('browser',None): cmdLine.komodo_browser = key break if cmdLine.komodo_browser is None: cmdLine.komodo_browser = CLA_BROWSER_OPTIONS[0][0] # set it to NA if case.pg_type == 'SI': cmdLine.komodo_pgsim = True else: cmdLine.komodo_pgsim = False return cmdLine # Get the parameters case = Case.objects.get(id=cid) data = handleAjaxRequestJSONData(request) # Check to see if there are planned exec ids in the POST data, this means # that we are editing command line params if 'pe' in data: # If there is only one delete_select_####=on, then this is a single edit if len(data['pe'].split('&')) == 1: peid = int(data['pe'].split('=')[0].split('_')[-1]) cmdLine, created = CommandLineArgs.objects.get_or_create(planned_exec=peid) # Multiples, can't assume previously chosen params else: cmdLine = _createCommandLineArgsInstance(case, data) # No command line args edit, this is a new planned execution else: cmdLine = _createCommandLineArgsInstance(case, data) # Create a form instance form = CommandLineArgsForm(case, instance=cmdLine, label_suffix='') hidePGExternal = False hideMultiEdit = False form_id = data.get('form_id', 'command_line_args_form') if data.get('all_centricity', None) == 'true': hidePGExternal = True elif data.get('edit_params', None) == 'true': hidePGExternal = True hideMultiEdit = True else: hidePGExternal = False objContext = RequestContext(request, {'form': form, 'form_id': form_id, 'case': case, 'hideMultiEdit': hideMultiEdit, 'hidePGExternal': hidePGExternal}) return render_to_response('forms/command_line_args_generic.html', objContext)