Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
re2o
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nounous
re2o
Commits
8c2b2ca8
Commit
8c2b2ca8
authored
May 03, 2018
by
Maël Kervella
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix #111 properly
parent
dcd1e2af
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
16 deletions
+13
-16
re2o/utils.py
re2o/utils.py
+10
-14
templates/pagination.html
templates/pagination.html
+3
-2
No files found.
re2o/utils.py
View file @
8c2b2ca8
...
@@ -340,20 +340,16 @@ def re2o_paginator(request, query_set, pagination_number):
...
@@ -340,20 +340,16 @@ def re2o_paginator(request, query_set, pagination_number):
:request:
:request:
:query_set: Query_set to paginate
:query_set: Query_set to paginate
:pagination_number: Number of entries to display"""
:pagination_number: Number of entries to display"""
if
query_set
.
count
()
>
pagination_number
:
paginator
=
Paginator
(
query_set
,
pagination_number
)
paginator
=
Paginator
(
query_set
,
pagination_number
)
page
=
request
.
GET
.
get
(
'page'
)
page
=
request
.
GET
.
get
(
'page'
)
try
:
try
:
results
=
paginator
.
page
(
page
)
results
=
paginator
.
page
(
page
)
except
PageNotAnInteger
:
except
PageNotAnInteger
:
# If page is not an integer, deliver first page.
# If page is not an integer, deliver first page.
results
=
paginator
.
page
(
1
)
results
=
paginator
.
page
(
1
)
except
EmptyPage
:
except
EmptyPage
:
# If page is out of range (e.g. 9999), deliver last page of results.
# If page is out of range (e.g. 9999), deliver last page of results.
results
=
paginator
.
page
(
paginator
.
num_pages
)
results
=
paginator
.
page
(
paginator
.
num_pages
)
else
:
#If there is only one page, deliver the page without paginator
return
query_set
return
results
return
results
...
...
templates/pagination.html
View file @
8c2b2ca8
...
@@ -24,6 +24,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
...
@@ -24,6 +24,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% load url_insert_param %}
{% load url_insert_param %}
{% if list.paginator.num_pages > 1 %}
<ul
class=
"pagination nav navbar-nav"
>
<ul
class=
"pagination nav navbar-nav"
>
{% if list.has_previous %}
{% if list.has_previous %}
<li><a
href=
"{% url_insert_param request.get_full_path page=1 %}"
>
<
<
</
a
></li>
<li><a
href=
"{% url_insert_param request.get_full_path page=1 %}"
>
<
<
</
a
></li>
...
@@ -39,5 +40,5 @@ with this program; if not, write to the Free Software Foundation, Inc.,
...
@@ -39,5 +40,5 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<li><a
href=
"{% url_insert_param request.get_full_path page=list.next_page_number %}"
>
>
</a></li>
<li><a
href=
"{% url_insert_param request.get_full_path page=list.next_page_number %}"
>
>
</a></li>
<li><a
href=
"{% url_insert_param request.get_full_path page=list.paginator.page_range|length %}"
>
>>
</a></li>
<li><a
href=
"{% url_insert_param request.get_full_path page=list.paginator.page_range|length %}"
>
>>
</a></li>
{% endif %}
{% endif %}
</ul>
</ul>
{% endif %}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment