Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
Carlos Ribas
rnacentral-webcode
Commits
53e4d888
Commit
53e4d888
authored
May 26, 2021
by
carlosribas
Browse files
Remove unused class
parent
cf9d4e8a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
33 deletions
+2
-33
rnacentral/rnacentral/utils/pagination.py
rnacentral/rnacentral/utils/pagination.py
+2
-33
No files found.
rnacentral/rnacentral/utils/pagination.py
View file @
53e4d888
from
django.db.models.query
import
RawQuerySet
from
django.db.models
import
sql
from
django.core.paginator
import
Paginator
from
rest_framework.pagination
import
PageNumberPagination
...
...
@@ -20,6 +19,8 @@ class PaginatedRawQuerySet(RawQuerySet):
https://stackoverflow.com/questions/32191853/best-way-to-paginate-a-raw-sql-query-in-a-django-rest-listapi-view/43921793#43921793
https://gist.github.com/eltongo/d3e6bdef17b0b14384ba38edc76f25f6
Stopped working after Django migration, but will keep it just in case.
"""
def
__init__
(
self
,
raw_query
,
**
kwargs
):
super
(
PaginatedRawQuerySet
,
self
).
__init__
(
raw_query
,
**
kwargs
)
...
...
@@ -99,35 +100,3 @@ class PaginatedRawQuerySet(RawQuerySet):
clone
=
self
.
__class__
(
raw_query
=
self
.
raw_query
,
model
=
self
.
model
,
using
=
self
.
_db
,
hints
=
self
.
_hints
,
query
=
self
.
query
,
params
=
self
.
params
,
translations
=
self
.
translations
)
return
clone
class
RawQuerysetPaginator
(
Paginator
):
"""
This is a Django paginator, meant to adapt RawQueryset
to DRF pagination classes.
Stolen from:
https://stackoverflow.com/questions/2532475/django-paginator-raw-sql-query
Stopped using it in favor of PaginatedRawQueryset, but will keep it just in case.
"""
def
__init__
(
self
,
object_list
,
per_page
,
count
=
1
,
**
kwargs
):
super
(
RawQuerysetPaginator
,
self
).
__init__
(
object_list
,
per_page
,
**
kwargs
)
self
.
_raw_count
=
count
@
property
def
count
(
self
):
return
self
.
_raw_count
def
page
(
self
,
number
):
number
=
self
.
validate_number
(
number
)
return
self
.
_get_page
(
self
.
object_list
,
number
,
self
)
class
RawQuerysetPagination
(
Pagination
):
"""
DRF pagination_class for raw querysets.
Stopped using it in favor of PaginatedRawQueryset, but will keep it just in case.
"""
django_paginator_class
=
RawQuerysetPaginator
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