# Path: mass_flask_core/utils/pagination_functions.py
# class PaginationFunctions:
#     @staticmethod
#     def paginate(view_function):
#         @wraps(view_function)
#         def paginate_function(*args, **kwargs):
#             if 'page' in request.args:
#                 page = int(request.args['page'])
#             else:
#                 page = 1
#             per_page = current_app.config['OBJECTS_PER_PAGE']
#             queryset = view_function(*args, **kwargs)
#             page_count = ceil(queryset.count()/per_page)
#             paginated_queryset = queryset.paginate(page=page, per_page=per_page)
#             result = {
#                 'results': paginated_queryset.items,
#                 'next': _get_page_link(paginated_queryset.next_num) if paginated_queryset.has_next else None,
#                 'previous': _get_page_link(paginated_queryset.prev_num) if paginated_queryset.has_prev else None,
#                 'page': page,
#                 'page_count': page_count
#             }
#             return result
#         return paginate_function


from flask import jsonify, request
from flask.views import MethodView
from mongoengine import DoesNotExist
from datetime import datetime
from mass_flask_core.utils import PaginationFunctions
    filter_parameters = []

    @staticmethod
    def _create_date_from_string(string):
        return datetime.strptime(string, '%Y-%m-%dT%H:%M:%S+00:00')

    @staticmethod
    def _create_list_from_string(string):
        return string.split(',')

    @property
    def schema(self):
        return Ref('schema').resolve(self)

    @property
    def pagination_schema(self):
        return Ref('pagination_schema').resolve(self)

    @property
    def queryset(self):
        return Ref('queryset').resolve(self)

    @property
    def query_key_field(self):
        return Ref('query_key_field').resolve(self)

    @property
    def filter_parameters(self):
        return Ref('filter_parameters').resolve(self)


# Path: mass_flask_core/utils/pagination_functions.py
# class PaginationFunctions:
#     @staticmethod
#     def paginate(view_function):
#         @wraps(view_function)
#         def paginate_function(*args, **kwargs):
#             if 'page' in request.args:
#                 page = int(request.args['page'])
#             else:
#                 page = 1
#             per_page = current_app.config['OBJECTS_PER_PAGE']
#             queryset = view_function(*args, **kwargs)
#             page_count = ceil(queryset.count()/per_page)
#             paginated_queryset = queryset.paginate(page=page, per_page=per_page)
#             result = {
#                 'results': paginated_queryset.items,
#                 'next': _get_page_link(paginated_queryset.next_num) if paginated_queryset.has_next else None,
#                 'previous': _get_page_link(paginated_queryset.prev_num) if paginated_queryset.has_prev else None,
#                 'page': page,
#                 'page_count': page_count
#             }
#             return result
#         return paginate_function


# Path: mass_flask_api/resources/base.py
from flask import jsonify, request
from flask.views import MethodView
from mongoengine import DoesNotExist
from datetime import datetime
from mass_flask_core.utils import PaginationFunctions

    filter_parameters = []

    @staticmethod
    def _create_date_from_string(string):
        return datetime.strptime(string, '%Y-%m-%dT%H:%M:%S+00:00')

    @staticmethod
    def _create_list_from_string(string):
        return string.split(',')

    @property
    def schema(self):
        return Ref('schema').resolve(self)

    @property
    def pagination_schema(self):
        return Ref('pagination_schema').resolve(self)

    @property
    def queryset(self):
        return Ref('queryset').resolve(self)

    @property
    def query_key_field(self):
        return Ref('query_key_field').resolve(self)

    @property
    def filter_parameters(self):
        return Ref('filter_parameters').resolve(self)


    @PaginationFunctions.paginate