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:
Nicholas Staples
2016-04-19 10:52:52 +01:00
parent 58ab831df9
commit 31978bd987
4 changed files with 74 additions and 11 deletions

View File

@@ -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):