def get_states(): """ 获取所有状态信息 分页查询 """ states = '' if request.method == 'GET': states = State.query.filter().all() if request.method == 'POST': stateName = request.form.get('stateName') itemId = request.form.get('itemName') if stateName == "" and itemId == "": states = State.query.filter().all() else: filterList = [] if stateName != "": filterList.append(State.s_value.like("%" + stateName + "%")) if itemId != "": filterList.append(State.s_item_code == itemId) states = State.query.filter(*filterList).all() li = [] for i in range(0, len(states)): li.append(states[i]) pager_obj = Pagination(request.args.get("page", 1), len(li), request.path, request.args, per_page_count=10) states = li[pager_obj.start:pager_obj.end] items = Item.query.filter().all() html = pager_obj.page_html() return render_template('state-list.html', html=html, states=states, items=items)
def get_items(): """ 获取所有分类信息 分页查询 """ itemName = '' if request.method == 'POST': itemName = request.form.get('itemName') items = Item.query.filter(Item.i_value.like("%" + itemName + "%") if itemName is not None else "").all() li = [] for i in range(0, len(items)): li.append(items[i]) pager_obj = Pagination(request.args.get("page", 1), len(li), request.path, request.args, per_page_count=10) items = li[pager_obj.start:pager_obj.end] html = pager_obj.page_html() return render_template('item-list.html', html=html, items=items)
def get_modules(): """ 获取所有模块信息 分页查询 """ modules = "" if request.method == 'GET': modules = Module.query.filter().all() if request.method == 'POST': moduleName = request.form.get('moduleName') start = request.form.get('start') end = request.form.get('end') moduleState = request.form.get('module_state') user = request.form.get('user') if moduleName == "" and moduleState == "" and start == "" and end == "" and user == "": modules = Module.query.filter().all() else: filterList = [] if moduleName != "": filterList.append(Module.m_name.like("%" + moduleName + "%")) if user != "": filterList.append(Module.m_create_user_id == user) if moduleState != "": filterList.append(Module.m_state == moduleState) if start != "" and end != "": filterList.append(Module.m_create_time.__gt__(start)) filterList.append(Module.m_create_time.__lt__(end)) modules = Module.query.filter(*filterList).all() li = [] for i in range(0, len(modules)): li.append(modules[i]) pager_obj = Pagination(request.args.get("page", 1), len(li), request.path, request.args, per_page_count=10) modules = li[pager_obj.start:pager_obj.end] html = pager_obj.page_html() states = State.query.filter(State.s_item_code == 2).all() users = User.query.filter().all() # logger.info(states) return render_template('module-list.html', html=html, modules=modules, states=states, users=users)
def get_cases(): """ 获取所有测试用例集信息 分页查询 """ cases = "" if request.method == 'GET': cases = Cases.query.filter().all() if request.method == 'POST': casesName = request.form.get('casesName') start = request.form.get('start') end = request.form.get('end') user = request.form.get('user') casesInModule = request.form.get('casesInModule') if casesName == "" and start == "" and end == "" and user == "" and casesInModule == "": cases = Cases.query.filter().all() else: filterList = [] if casesName != "": filterList.append(Cases.cs_name.like("%" + casesName + "%")) if user != "": filterList.append(Cases.cs_create_user_id == user) if casesInModule != "": filterList.append(Cases.cs_in_module_id == casesInModule) if start != "" and end != "": filterList.append(Cases.cs_create_time.__gt__(start)) filterList.append(Cases.cs_create_time.__lt__(end)) cases = Cases.query.filter(*filterList).all() li = [] for i in range(0, len(cases)): li.append(cases[i]) pager_obj = Pagination(request.args.get("page", 1), len(li), request.path, request.args, per_page_count=10) cases = li[pager_obj.start:pager_obj.end] html = pager_obj.page_html() users = User.query.filter().all() modules = Module.query.filter().all() # logger.info(states) return render_template('cases-list.html', html=html, cases=cases, users=users, modules=modules)
def soaps(): """ 获取所有soap执行任务服务 分页查询 """ soaps = "" if request.method == 'GET': soaps = Soap.query.filter().all() if request.method == 'POST': soap_method = request.form.get('soap_method') soap_call_timing = request.form.get('soap_call_timing') start = request.form.get('start') end = request.form.get('end') user = request.form.get('user') if soap_method == "" and soap_call_timing == "" and start == "" and end == "" and user == "": soaps = Soap.query.filter().all() else: filterList = [] if soap_method != "": filterList.append( Soap.soap_method.like("%" + soap_method + "%")) if soap_call_timing != "": filterList.append( Soap.soap_call_timing.like("%" + soap_call_timing + "%")) if user != "": filterList.append(Soap.soap_create_user_id == user) if start != "" and end != "": filterList.append(Soap.soap_create_time.__gt__(start)) filterList.append(Soap.soap_create_time.__lt__(end)) soaps = Soap.query.filter(*filterList).all() li = [] for i in range(0, len(soaps)): li.append(soaps[i]) pager_obj = Pagination(request.args.get("page", 1), len(li), request.path, request.args, per_page_count=10) soaps = li[pager_obj.start:pager_obj.end] html = pager_obj.page_html() users = User.query.filter().all() return render_template('soap-list.html', html=html, soaps=soaps, users=users)
def get_task(tk_type): """ 获取所有定时任务信息 分页查询 """ tasks = "" projects = Project.query.filter().all() if request.method == 'GET': tasks = Task.query.filter(Task.tk_type == tk_type).all() if request.method == 'POST': tk_name = request.form.get('tk_name') start = request.form.get('start') end = request.form.get('end') state = request.form.get('state') user = request.form.get('user') if tk_name == "" and state == "" and start == "" and end == "" and user == "": tasks = Task.query.filter().all() else: filterList = [] if tk_name != "": filterList.append(Task.tk_name.like("%" + tk_name + "%")) if user != "": filterList.append(Task.tk_create_user_id == user) if start != "" and end != "": filterList.append(Task.tk_create_time.__gt__(start)) filterList.append(Task.tk_create_time.__lt__(end)) filterList.append(Task.tk_type == tk_type) tasks = Task.query.filter(*filterList).all() li = [] for i in range(0, len(tasks)): li.append(tasks[i]) pager_obj = Pagination(request.args.get("page", 1), len(li), request.path, request.args, per_page_count=10) tasks = li[pager_obj.start:pager_obj.end] html = pager_obj.page_html() users = User.query.filter().all() # logger.info(states) return render_template('task-list.html', html=html, tasks=tasks, projects=projects, users=users)
def shows(): """ 获取所有注册服务 分页查询 """ methods = "" if request.method == 'GET': methods = Methods.query.filter().all() if request.method == 'POST': methodName = request.form.get('methodName') start = request.form.get('start') end = request.form.get('end') user = request.form.get('user') if methodName == "" and start == "" and end == "" and user == "": methods = Methods.query.filter().all() else: filterList = [] if methodName != "": filterList.append( Methods.md_method.like("%" + methodName + "%")) if user != "": filterList.append(Methods.md_create_user_id == user) if start != "" and end != "": filterList.append(Methods.md_create_time.__gt__(start)) filterList.append(Methods.md_create_time.__lt__(end)) methods = Methods.query.filter(*filterList).all() li = [] for i in range(0, len(methods)): li.append(methods[i]) pager_obj = Pagination(request.args.get("page", 1), len(li), request.path, request.args, per_page_count=10) methods = li[pager_obj.start:pager_obj.end] html = pager_obj.page_html() users = User.query.filter().all() return render_template('method-regiest.html', html=html, methods=methods, users=users)
filterList.append(Testcase.tc_create_time.__gt__(start)) filterList.append(Testcase.tc_create_time.__lt__(end)) caselist = Testcase.query.filter(*filterList).all() for case in caselist: testcase = Testcase.query.filter( Testcase.tc_id == case.tc_link_case).first() if testcase is not None: case.parent_name = testcase.tc_name else: case.parent_name = "无" li = [] for i in range(0, len(caselist)): li.append(caselist[i]) pager_obj = Pagination(request.args.get("page", 1), len(li), request.path, request.args, per_page_count=10) caselist = li[pager_obj.start:pager_obj.end] html = pager_obj.page_html() users = User.query.filter().all() modules = Module.query.filter().all() return render_template('case-list.html', html=html, caselist=caselist, users=users, modules=modules) @case_blueprint.route('/addTestCase/', methods=['GET', 'POST']) @is_login