예제 #1
0
def operationTask(request, context):
    langDict = getLangTextDict(request)

    context["option"] = request.GET.get("option")
    context["page"] = 1
    if not isRelease:
        context["env"] = "test"
    try:
        if VersionService.isCurrentVersion(request):
            context["dataAddBy"] = HTTP_taskService.getTaskForId(
                request.GET.get("id")).addBy.loginName
        else:
            context["dataAddBy"] = HTTP_taskService.getVersionTaskForId(
                request.GET.get("id"),
                request.session.get("version")).addBy.loginName

    except Exception as e:
        print(traceback.format_exc())
        return render(request, "permission/page_404.html")

    context["checkBusinessLine"] = dbModelListToListDict(
        BusinessService.getAllBusinessLine())
    context["checkModules"] = dbModelListToListDict(
        ModulesService.getAllModules())
    context["id"] = request.GET.get("id")
    context["interfacePage"] = 1
    context["testCasePage"] = 1
    context["taskAdd"] = "current-page"
    text = {}
    text["pageTitle"] = langDict["web"]["httpTaskPageHeadings_%s" %
                                        context["option"]]
    context["text"] = text
    context.update(getServiceConf(request))
    return render(request, "InterfaceTest/HTTPTask/HTTP_taskAdd.html", context)
예제 #2
0
def queryVars(request):

    page = request.POST.get("page")
    if isInt(page):
        page = int(page)
    else:
        return HttpResponse("<script>alert('请验证页数参数');</script>")

    checkArr = json.loads(parse.unquote(request.POST.get("queryArr")))

    orderBy = request.POST.get("orderBy")
    if isSqlInjectable(orderBy):
        return HttpResponse("<script>alert('查询条件非法');</script>")

    #根据版本判断应该从哪个表里取数据 王吉亮添加于20180224
    if VersionService.isCurrentVersion(request):
        tbName = "tb_global_vars"
        versionCondition = ""
    else:
        tbName = "tb_version_global_vars"
        versionCondition = "and versionName='%s'" % request.session.get(
            "version")

    execSql = "SELECT g.*,u.userName,umod.userName modByName FROM %s g LEFT JOIN tb_user u ON g.addBy = u.loginName  LEFT JOIN tb_user umod ON g.modBy = umod.loginName WHERE g.state=1 %s " % (
        tbName, versionCondition)
    checkList = []
    for key in checkArr:
        if checkArr[key] == "":
            continue
        elif key == "addBy":
            checkList.append("%%%s%%" % checkArr[key])
            checkList.append("%%%s%%" % checkArr[key])
            execSql += """ and (g.addBy LIKE %s or u.userName LIKE %s) """

            continue
        checkList.append("%%%s%%" % checkArr[key])
        execSql += """ and g.%s """ % key
        execSql += """ LIKE %s"""
    execSql += """ ORDER BY %s""" % orderBy
    context = pagination(sqlStr=execSql,
                         attrList=checkList,
                         page=page,
                         pageNum=commonWebConfig.testCasePageNum,
                         request=request)

    context.update(getServiceConf(request))
    response = render(
        request,
        "InterfaceTest/user_center/SubPages/global_vars_conf_sub_page.html",
        context)
    return response
예제 #3
0
def taskSuiteAdd(request, context):
    langDict = getLangTextDict(request)
    context["interfacePage"] = 1
    context["testCasePage"] = 1
    context["option"] = "add"
    if not isRelease:
        context["env"] = "test"
    context["taskSuiteAdd"] = "current-page"
    context["checkBusinessLine"] = dbModelListToListDict(
        BusinessService.getAllBusinessLine())
    context["checkModules"] = dbModelListToListDict(
        ModulesService.getAllModules())
    context.update(getServiceConf(request))
    text = {}
    text["pageTitle"] = langDict["web"]["httpTaskSuitePageHeadings_%s" %
                                        context["option"]]
    text["subPageTitle"] = langDict["web"]["httpTaskSuiteSubPageTitle_%s" %
                                           context["option"]]
    context["text"] = text
    return render(request, "dubbo/taskSuite/taskSuiteAdd.html", context)
예제 #4
0
def globalTextCheck(request):
    langDict = getLangTextDict(request)
    context = {}

    context["httpUserCenterGlobalTextPage"] = "current-page"
    context["userName"] = request.session.get("userName")
    if not isRelease:
        context["env"] = "test"
    # 文本
    text = {}
    text["pageTitle"] = langDict["web"]["httpUserCenterGlobalTextPageTitle"]
    text["subPageTitle"] = langDict["web"][
        "httpUserCenterGlobalTextSubPageTitle"]

    context["text"] = text
    context["title"] = "组合文本"

    context.update(getServiceConf(request))
    context["page"] = 1
    return render(request, "InterfaceTest/user_center/global_text_conf.html",
                  context)
예제 #5
0
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)
예제 #6
0
def getTaskSuiteForTaskSuiteId(request):
    langDict = getLangTextDict(request)
    id = request.GET.get("id")
    if VersionService.isCurrentVersion(request):
        taskData = dubbo_taskSuiteService.getTaskSuiteForId(id)
    else:
        taskData = dubbo_taskSuiteService.getTaskSuiteForId(id)
        # taskData = HTTP_taskService.getVersionTaskForTaskId(taskId, VersionService.getVersionName(request))

    if not taskData:
        return HttpResponse(ApiReturn(ApiReturn.CODE_TASK_EXCEPITON).toJson())
    taskSuiteDataDict = dbModelToDict(taskData)
    taskSuiteDataDict["userName"] = TbUser.objects.get(
        loginName=taskData.addBy).userName
    context = {}
    context.update(getServiceConf(request))
    envConfList = DubboInterfaceService.queryDubboConfSort(request)
    context["httpConf"] = envConfList
    context["taskSuiteData"] = taskSuiteDataDict
    context["option"] = request.GET.get("option")
    return render(request,
                  "dubbo/taskSuite/SubPages/task_suite_run_details_page.html",
                  context)