fix list page
Showing
1 changed file
with
7 additions
and
5 deletions
... | @@ -252,18 +252,20 @@ class DocView(GenericView, DocHandler): | ... | @@ -252,18 +252,20 @@ class DocView(GenericView, DocHandler): |
252 | query = application_id_query & status_query & data_source_query & upload_finish_time_query & create_time_query | 252 | query = application_id_query & status_query & data_source_query & upload_finish_time_query & create_time_query |
253 | val_tuple = ('id', 'application_id', 'upload_finish_time', 'create_time', 'data_source', 'status') | 253 | val_tuple = ('id', 'application_id', 'upload_finish_time', 'create_time', 'data_source', 'status') |
254 | doc_class, prefix = self.get_doc_class(business_type) | 254 | doc_class, prefix = self.get_doc_class(business_type) |
255 | doc_queryset = doc_class.objects.filter(query).values(*val_tuple).order_by('-create_time') | 255 | total = doc_class.objects.filter(query).count() |
256 | doc_list = self.get_doc_list(doc_queryset, prefix) | ||
257 | |||
258 | total = len(doc_list) | ||
259 | start_index = page_size * (page - 1) | 256 | start_index = page_size * (page - 1) |
260 | end_index = page_size * page | 257 | end_index = page_size * page |
261 | if start_index >= total > 0: | 258 | if start_index >= total > 0: |
262 | raise self.invalid_params('页数不存在') | 259 | raise self.invalid_params('页数不存在') |
260 | |||
261 | doc_queryset = doc_class.objects.filter(query).values(*val_tuple).order_by('-create_time')[start_index: end_index] | ||
262 | doc_list = self.get_doc_list(doc_queryset, prefix) | ||
263 | |||
264 | # total = len(doc_list) | ||
263 | pagination = {'current': page, 'total': total, 'page_size': page_size} | 265 | pagination = {'current': page, 'total': total, 'page_size': page_size} |
264 | res = { | 266 | res = { |
265 | 'pagination': pagination, | 267 | 'pagination': pagination, |
266 | 'doc_list': doc_list[start_index: end_index] | 268 | 'doc_list': doc_list |
267 | } | 269 | } |
268 | self.running_log.info('[get doc list] [args={0}] [res={1}]'.format(args, res)) | 270 | self.running_log.info('[get doc list] [args={0}] [res={1}]'.format(args, res)) |
269 | return response.ok(data=res) | 271 | return response.ok(data=res) | ... | ... |
-
Please register or sign in to post a comment