Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def add_task_webcase_test(request):
username = request.session.get('user', '')
tasks = webtest_task.objects.all()
if request.method == "POST":
objs = request.POST.get("objstring")
obj = json.loads(objs)
for i in range(0, len(obj)):
id=int(obj[i]['id'])
webcase_models = obj[i]['webcase_models']
webcasename = obj[i]['webcasename']
webcasedesc = obj[i]['webcasedesc']
webtest_task.objects.create(case_id=id,task_modelname=webcase_models,task_casename=webcasename,task_stepdesc=webcasedesc)
return render(request, "webcase_periodic_task.html",{"user": username, "tasks": tasks})
def run_webcase_immediately(request):
username = request.session.get('user', '')
tasks = webtest_task.objects.all()
if request.method == "POST":
write_name_txt()
time.sleep(2)
get_task_stepdata()
time.sleep(1)
run_in_terminal()
return render(request, "webcase_periodic_task.html", {"user": username, "tasks": tasks})
def webUI_periodic_task(request):
username = request.session.get('user','')
tasks = webtest_task.objects.all()
cases = Webcase.objects.all()
singel_tasks = webtest_task.objects.get_queryset().order_by('task_id')
paginator = Paginator(singel_tasks, 15) # 生成paginator对象,设置每页显示15条记录
page = request.GET.get('page', 1) # 获取当前页为第1页
currentPage = int(page) # 把当前页转换成整数
try:
singel_tasks = paginator.page(page) # 获取当前页码数的记录列表
except PageNotAnInteger:
singel_tasks = paginator.page(1) # 如果输入的页数不是整数则显示第1页内容
except EmptyPage:
singel_tasks = paginator.page(paginator.num_pages) # 如果输入的的页数不在系统的页数中,则显示最后一页
return render(request, "webcase_periodic_task.html", {"user": username, "singel_tasks": singel_tasks,"cases":cases,"tasks": tasks})