mirror of
https://github.com/GSA/notifications-api.git
synced 2026-09-09 09:19:48 -04:00
Added page_size parameter for notifications api. All tests passing.
Add page_size and total parameters to all calls for notifications.
This commit is contained in:
@@ -234,6 +234,7 @@ class NotificationsFilterSchema(ma.Schema):
|
||||
template_type = fields.Nested(BaseTemplateSchema, only=['template_type'], many=True)
|
||||
status = fields.Nested(NotificationModelSchema, only=['status'], many=True)
|
||||
page = fields.Int(required=False)
|
||||
page_size = fields.Int(required=False)
|
||||
|
||||
@pre_load
|
||||
def handle_multidict(self, in_data):
|
||||
@@ -254,8 +255,7 @@ class NotificationsFilterSchema(ma.Schema):
|
||||
in_data['status'] = [x.status for x in in_data['status']]
|
||||
return in_data
|
||||
|
||||
@validates('page')
|
||||
def validate_page(self, value):
|
||||
def _validate_positive_number(self, value):
|
||||
try:
|
||||
page_int = int(value)
|
||||
if page_int < 1:
|
||||
@@ -263,6 +263,14 @@ class NotificationsFilterSchema(ma.Schema):
|
||||
except:
|
||||
raise ValidationError("Not a positive integer")
|
||||
|
||||
@validates('page')
|
||||
def validate_page(self, value):
|
||||
self._validate_positive_number(value)
|
||||
|
||||
@validates('page_size')
|
||||
def validate_page_size(self, value):
|
||||
self._validate_positive_number(value)
|
||||
|
||||
|
||||
class TemplateStatisticsSchema(BaseSchema):
|
||||
|
||||
|
||||
Reference in New Issue
Block a user