#task_histories_detail

This commit is contained in:
xieshen 2020-11-06 15:04:55 +08:00
parent 9da2ba7f42
commit 52c8dbaa9c
1 changed files with 7 additions and 5 deletions

View File

@ -1,4 +1,5 @@
import json import json
import math
from django.core.paginator import Paginator, PageNotAnInteger, EmptyPage from django.core.paginator import Paginator, PageNotAnInteger, EmptyPage
from django.db import connection from django.db import connection
@ -151,13 +152,13 @@ def task_histories_detail(request, pk):
paginator = Paginator(row, 10) paginator = Paginator(row, 10)
page = int(request.GET.get('page', 1)) page = int(request.GET.get('page', 1))
try: try:
row = paginator.page(page) rows = paginator.page(page)
except PageNotAnInteger: except PageNotAnInteger:
row = paginator.page(1) rows = paginator.page(1)
except EmptyPage: except EmptyPage:
row = paginator.page(paginator.num_pages) rows = paginator.page(paginator.num_pages)
res = [] res = []
for r in row: for r in rows:
o = dict() o = dict()
o['id'] = r[0] o['id'] = r[0]
o['task_id'] = r[1] o['task_id'] = r[1]
@ -173,5 +174,6 @@ def task_histories_detail(request, pk):
return HttpResponse(json.dumps({ return HttpResponse(json.dumps({
"status":"1", "status":"1",
"res":res, "res":res,
"row":row, "count":len(row),
"page_count":math.ceil(len(row)/10),
})) }))