Example #1
0
 def post(self) -> tuple:
     user_data = self.user_service.get(**request.get_json())
     user_serializer = UserSerializer(many=True)
     return {
         'data': user_serializer.dump(list(user_data['query'])),
         'records_total': user_data['records_total'],
         'records_filtered': user_data['records_filtered'],
     }, 200
Example #2
0
def _get_user_data(request_data: dict) -> list:
    page_number, items_per_page, order_by = rqo.get_request_query_fields(
        UserModel, request_data)

    query = UserModel.select()
    query = rqo.create_search_query(UserModel, query, request_data)
    query = (query.order_by(*order_by).paginate(page_number, items_per_page))

    user_serializer = UserSerializer(many=True)
    user_list = user_serializer.dump(list(query))

    return user_list