Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
81ced1c9
Commit
81ced1c9
authored
Aug 25, 2015
by
Bill DeRusha
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove disable pylint for paginator error and fix syntax
parent
4c03b2bb
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
7 deletions
+8
-7
openedx/core/lib/api/paginators.py
+8
-7
No files found.
openedx/core/lib/api/paginators.py
View file @
81ced1c9
""" Paginatator methods for edX API implementations."""
from
django.http
import
Http404
from
django.utils.translation
import
ugettext
as
_
from
django.core.paginator
import
Paginator
,
InvalidPage
...
...
@@ -26,15 +25,17 @@ def paginate_search_results(object_class, search_results, page_size, page):
if
page
==
'last'
:
page_number
=
paginator
.
num_pages
else
:
raise
Http404
(
_
(
"Page is not 'last', nor can it be converted to an int."
)
)
raise
Http404
(
"Page is not 'last', nor can it be converted to an int."
)
try
:
paged_results
=
paginator
.
page
(
page_number
)
except
InvalidPage
as
e
:
# pylint: disable=invalid-name
raise
Http404
(
_
(
'Invalid page (
%(page_number)
s):
%(message)
s'
)
%
{
'page_number'
:
page_number
,
'message'
:
str
(
e
)
})
except
InvalidPage
as
exception
:
raise
Http404
(
"Invalid page {page_number}: {message}"
.
format
(
page_number
=
page_number
,
message
=
str
(
exception
)
)
)
search_queryset_pks
=
[
item
[
'data'
][
'pk'
]
for
item
in
paged_results
.
object_list
]
queryset
=
object_class
.
objects
.
filter
(
pk__in
=
search_queryset_pks
)
...
...
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