Skip to content

Commit

Permalink
fix bug for load project list bug
Browse files Browse the repository at this point in the history
  • Loading branch information
LoRexxar committed Dec 27, 2021
1 parent 2a8aa5b commit c8888a5
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions web/dashboard/controller/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,17 @@ def get_context_data(self, **kwargs):
rows = Project.objects.all().order_by('-id')
project_count = Project.objects.all().count()

context['projects'] = rows
if 'p' in self.request.GET:
page = int(self.request.GET['p'])
else:
page = 1

# check page
if page*50 > project_count:
page = 1

context['projects'] = rows[(page-1)*50: page*50]
context['page'] = page

for project in context['projects']:

Expand All @@ -61,17 +71,7 @@ def get_context_data(self, **kwargs):

context['projects'] = sorted(context['projects'], key=lambda x:x.last_scan_time)[::-1]

if 'p' in self.request.GET:
page = int(self.request.GET['p'])
else:
page = 1

# check page
if page*50 > project_count:
page = 1

context['projects'] = context['projects'][(page-1)*50: page*50]
context['page'] = page
# context['projects'] = context['projects'][(page-1)*50: page*50]

max_page = project_count // 50 if project_count % 50 == 0 else (project_count // 50)+1
max_page = max_page+1 if max_page == 1 else max_page
Expand Down

0 comments on commit c8888a5

Please sign in to comment.