mirror of
https://github.com/ilri/dspace-statistics-api.git
synced 2024-11-22 14:25:01 +01:00
Make sure limit is between 1 and 100
We were not properly checking whether the limit was greater than 0 in all cases.
This commit is contained in:
parent
1904c243a4
commit
ca1582a8b6
@ -17,7 +17,7 @@ class AllItemsResource:
|
|||||||
def on_get(self, req, resp):
|
def on_get(self, req, resp):
|
||||||
"""Handles GET requests"""
|
"""Handles GET requests"""
|
||||||
# Return HTTPBadRequest if id parameter is not present and valid
|
# Return HTTPBadRequest if id parameter is not present and valid
|
||||||
limit = req.get_param_as_int("limit", min_value=0, max_value=100) or 100
|
limit = req.get_param_as_int("limit", min_value=1, max_value=100) or 100
|
||||||
page = req.get_param_as_int("page", min_value=0) or 0
|
page = req.get_param_as_int("page", min_value=0) or 0
|
||||||
offset = limit * page
|
offset = limit * page
|
||||||
|
|
||||||
|
@ -108,7 +108,7 @@ def validate_items_post_parameters(req, resp, resource, params):
|
|||||||
else:
|
else:
|
||||||
raise falcon.HTTPBadRequest(
|
raise falcon.HTTPBadRequest(
|
||||||
title="Invalid parameter",
|
title="Invalid parameter",
|
||||||
description='The "limit" parameter is invalid. The value must be an integer between 0 and 100.',
|
description='The "limit" parameter is invalid. The value must be an integer between 1 and 100.',
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
req.context.limit = 100
|
req.context.limit = 100
|
||||||
|
Loading…
Reference in New Issue
Block a user