def userHttpConfCheck(request): langDict = getLangTextDict(request) context = {} context["httpUserCenterUserHttpConfPage"] = "current-page" context["userName"] = request.session.get("userName") if not isRelease: context["env"] = "test" # 文本 text = {} text["pageTitle"] = langDict["web"]["httpUserCenterUserHttpConfPageTitle"] text["subPageTitle"] = langDict["web"][ "httpUserCenterUserHttpConfSubPageTitle"] context["text"] = text serviceConf = ServiceConfService.getServiceConf() context["services"] = serviceConf # context["uriServices"] = UriService.getUri(request) # context["dubboServices"] = dbModelListToListDict(TbConfigUri.objects.filter(state=1,protocol="DUBBO").order_by("level")) context["envConfList"] = HttpConfService.getAllHttpConf(request) # context["uri"] = UriService.getUri(request, "ALL") context["page"] = 1 context["title"] = "环境配置" return render(request, "InterfaceTest/user_center/user_http_conf.html", context)
def httpConfAdd(request): showMenuConfig = eval(confDict['COMMON']['showMenuConfig']) varData = json.loads(parse.unquote(request.POST.get("data"))) for index in showMenuConfig: if showMenuConfig[index] == 1: if index == "HttpInterface": varData["apiRunState"] = 1 if index == "DubboInterface": varData["dubboRunState"] = 1 varData["addBy"] = request.session.get("loginName") varData["serviceConfKey_id"] = varData["serviceConfKey"] del varData["serviceConfKey"] try: HttpConfService.httpConfAdd(varData) except Exception as e: return HttpResponse( ApiReturn(ApiReturn.CODE_GLOBAL_EXCEPITON, "key重复%s" % e).toJson()) return HttpResponse(ApiReturn().toJson())
def getHttpConfData(request): id = request.GET.get("id") httpConfData = dbModelToDict(HttpConfService.getHttpConfForId(id)) httpConfList = httpConfData["httpConf"].split("\n") result = [] loop = 0 for httpConfIndex in range(1, len(httpConfList)): if httpConfList[httpConfIndex] == "" or "=" not in httpConfList[ httpConfIndex]: continue indexData = httpConfList[httpConfIndex].split("=") result.append({}) result[loop]["httpConfKey"] = indexData[0].strip() result[loop]["httpConfValue"] = indexData[1].strip() loop += 1 return HttpResponse(ApiReturn(body=result).toJson())
def taskResultCheck(request): langDict = getLangTextDict(request) context = {} if not isRelease: context["env"] = "test" context["taskExecuteResult"] = "current-page" context["checkBusinessLine"] = dbModelListToListDict( BusinessService.getAllBusinessLine()) context["checkModules"] = dbModelListToListDict( ModulesService.getAllModules()) context["httpConf"] = HttpConfService.queryHttpConfSort(request) # 文本 text = {} text["pageTitle"] = langDict["web"]["httpTaskCheckPageHeadings_check"] context["text"] = text context["page"] = 1 return render(request, "InterfaceTest/HTTPTask/HTTP_task_ExecResult.html", context)
def getVarsConf(request): id = request.GET.get("id") if VersionService.isCurrentVersion(request): varData = dbModelToDict(global_varsService.getVar(id)) else: varData = dbModelToDict(global_varsService.getVersionVar(id)) httpConfList = HttpConfService.queryUIRunHttpConfSort(request) varData["httpConf"] = {} varData["httpConf"]["common"] = substr(varData["varValue"], "[CONF=common]", "[ENDCONF]") for i in range(0, len(httpConfList)): if httpConfList[i]["httpConfKey"] not in varData["varValue"]: varData["httpConf"]["%s" % httpConfList[i]["httpConfKey"]] = "" continue varData["httpConf"]["%s" % httpConfList[i]["httpConfKey"]] = substr( varData["varValue"], "[CONF=%s]" % httpConfList[i]["httpConfKey"], "[ENDCONF]") return HttpResponse(ApiReturn(body=varData).toJson())
def userEnvUriCheck(request): langDict = getLangTextDict(request) context = {} context["httpUserCenterEnvURIConfPage"] = "current-page" context["userName"] = request.session.get("userName") if not isRelease: context["env"] = "test" # 文本 text = {} text["pageTitle"] = "请求地址配置" text["subPageTitle"] = "请求地址查看" context["text"] = text context["page"] = 1 context["envConfList"] = HttpConfService.getAllHttpConf(request) context["uri"] = UriService.getUri(request, "ALL") context["title"] = "请求地址配置" return render(request, "InterfaceTest/user_center/user_env_uri_conf.html", context)
def getTaskForId(request): langDict = getLangTextDict(request) id = request.GET.get("id") if VersionService.isCurrentVersion(request): taskData = HTTP_taskService.getTaskForId(id) else: taskData = HTTP_taskService.getVersionTaskForId( id, VersionService.getVersionName(request)) if not taskData: return HttpResponse(ApiReturn(ApiReturn.CODE_TASK_EXCEPITON).toJson()) taskDataDict = dbModelToDict(taskData) taskDataUser = dbModelToDict(taskData.addBy) del taskDataUser["id"] taskDataDict.update(taskDataUser) context = {} context.update(getServiceConf(request)) context["httpConf"] = HttpConfService.queryHttpConfSort(request) context["taskData"] = taskDataDict context["option"] = request.GET.get("option") return render(request, "InterfaceTest/HTTPTask/SubPages/task_Run_DetailsPage.html", context)
def getServiceConf(request): context = {} serviceConf = ServiceConfService.queryServiceConfSort(request) context["serviceCount"] = len(serviceConf) serviceIncludeHTTPConf = [] # serviceList = [] # 显示前置和后置变量的title for i in range(0, len(serviceConf)): # serviceList.append(serviceConf[i]["serviceConfKey"]) serviceIncludeHTTPConf.append( HttpConfService.getServiceIncludHttpConf( serviceConf[i]["serviceConfKey"])) httpConfStrList = "" for j in range(0, len(serviceIncludeHTTPConf[i])): if j == 0: httpConfStrList = "包含的环境:%s" % serviceIncludeHTTPConf[i][j][ "alias"] continue httpConfStrList = "%s,%s" % (httpConfStrList, serviceIncludeHTTPConf[i][j]["alias"]) serviceConf[i]["serviceIncludeHTTPConf"] = httpConfStrList context["service"] = serviceConf return context
def getHttpConfForUI(): context = {} serviceConf = HttpConfService.getHttpConfForUI() context["httpCount"] = len(serviceConf) context["httpConfList"] = serviceConf return context
def httpConfSaveEdit(request): data = json.loads(parse.unquote(request.POST.get("data"))) data["modTime"] = datetime.datetime.now() result = HttpConfService.httpConfEdit(data) return HttpResponse(ApiReturn().toJson())
def delHttpConfKey(request): id = request.GET.get("id") HttpConfService.httpConfDel(id) return HttpResponse(ApiReturn().toJson())
def delHttpConfKey(request): httpConfKey = request.GET.get("httpConfKey") HttpConfService.httpConfDel(httpConfKey) return HttpResponse(ApiReturn().toJson())