Skip to content

Commit

Permalink
Merge branch 'hotfix/0.126.20'
Browse files Browse the repository at this point in the history
  • Loading branch information
sloria committed Jan 10, 2018
2 parents de53f08 + 1635c15 commit 13ba89f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
3 changes: 3 additions & 0 deletions api/base/pagination.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,9 @@ class MaxSizePagination(JSONAPIPagination):
class NoMaxPageSizePagination(JSONAPIPagination):
max_page_size = None

class IncreasedPageSizePagination(JSONAPIPagination):
max_page_size = 1000

class CommentPagination(JSONAPIPagination):

def get_paginated_response(self, data):
Expand Down
3 changes: 2 additions & 1 deletion api/preprint_providers/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from api.base.exceptions import InvalidFilterValue, InvalidFilterOperator, Conflict
from api.base.filters import PreprintFilterMixin, ListFilterMixin
from api.base.views import JSONAPIBaseView
from api.base.pagination import MaxSizePagination
from api.base.pagination import MaxSizePagination, IncreasedPageSizePagination
from api.base.utils import get_object_or_error, get_user_auth, is_truthy
from api.licenses.views import LicenseList
from api.taxonomies.serializers import TaxonomySerializer
Expand Down Expand Up @@ -301,6 +301,7 @@ class PreprintProviderTaxonomies(JSONAPIBaseView, generics.ListAPIView):
required_write_scopes = [CoreScopes.NULL]

serializer_class = TaxonomySerializer
pagination_class = IncreasedPageSizePagination

ordering = ('-id',)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,21 @@ def setUp(self):
self.lawless_url = '/{}preprint_providers/{}/taxonomies/?page[size]=15&'.format(API_BASE, self.lawless_preprint_provider._id)
self.ruled_url = '/{}preprint_providers/{}/taxonomies/?page[size]=15&'.format(API_BASE, self.ruled_preprint_provider._id)

def test_max_page_size(self):
base_url = '/{}preprint_providers/{}/taxonomies/'.format(API_BASE, self.lawless_preprint_provider._id)

res = self.app.get(base_url)
assert_equal(res.status_code, 200)
assert_equal(res.json['links']['meta']['per_page'], 10)

res = self.app.get(base_url + '?page[size]=150')
assert_equal(res.status_code, 200)
assert_equal(res.json['links']['meta']['per_page'], 150)

res = self.app.get(base_url + '?page[size]=2018')
assert_equal(res.status_code, 200)
assert_equal(res.json['links']['meta']['per_page'], 1000)

def test_no_rules_grabs_all(self):
res = self.app.get(self.lawless_url)

Expand Down

0 comments on commit 13ba89f

Please sign in to comment.