Exemple #1
0
 def relation_instances(self,
                        item,
                        attribute,
                        target_resource,
                        page=None,
                        per_page=None):
     query = getattr(item, attribute)
     if page and per_page:
         return Pagination.from_list(query, page, per_page)
     else:
         return query.all()
Exemple #2
0
    def relation_instances(self, item, attribute, target_resource, page=None, per_page=None):
        query = getattr(item, attribute)

        if isinstance(query, InstrumentedList):
            if page and per_page:
                return Pagination.from_list(query, page, per_page)
            return query

        if page and per_page:
            return self._query_get_paginated_items(query, page, per_page)

        return self._query_get_all(query)
    def relation_instances(self, item, attribute, target_resource, page=None, per_page=None):
        query = getattr(item, attribute)

        if isinstance(query, InstrumentedList):
            if page and per_page:
                return Pagination.from_list(query, page, per_page)
            return query

        if page and per_page:
            return self._query_get_paginated_items(query, page, per_page)

        return self._query_get_all(query)
Exemple #4
0
 def relation_instances(self,
                        item,
                        attribute,
                        target_resource,
                        page=None,
                        per_page=None):
     query = getattr(item, attribute)
     if page and per_page:
         # TODO see if this can be better done in one query
         return Pagination(query.paginate(page, per_page), page, per_page,
                           query.count())
     return query
Exemple #5
0
    def relation_instances(self, item, attribute, target_resource, page=None, per_page=None):
        collection = item.get(attribute, set())

        items = []
        for id in collection:
            try:
                items.append(target_resource.manager.read(id))
            except ItemNotFound:
                collection.remove(id)
                pass

        return Pagination.from_list(items, page, per_page)
Exemple #6
0
    def relation_instances(self, item, attribute, target_resource, page=None, per_page=None):
        collection = item.get(attribute, set())

        items = []
        for id in collection:
            try:
                items.append(target_resource.manager.read(id))
            except ItemNotFound:
                collection.remove(id)
                pass

        return Pagination.from_list(items, page, per_page)
Exemple #7
0
 def paginated_instances_or(self,
                            page,
                            per_page,
                            where=None,
                            sort=None,
                            filter_or_cols=[],
                            filter_and_cols=[]):
     instances = self.instances_or(where=where,
                                   sort=sort,
                                   filter_or_cols=filter_or_cols,
                                   filter_and_cols=filter_and_cols)
     if isinstance(instances, list):
         return Pagination.from_list(instances, page, per_page)
     return self._query_get_paginated_items(instances, page, per_page)
Exemple #8
0
    def relation_instances(self, item, attribute, target_resource, page=None, per_page=None):
        query = getattr(item, attribute)

        if isinstance(query, InstrumentedList):
            if page and per_page:
                return Pagination.from_list(query, page, per_page)
            return query

        target_manager = target_resource.manager
        if isinstance(target_manager, PrincipalMixin):
            query = target_manager._query_filter_read_permission(query)

        if page and per_page:
            return target_manager._query_get_paginated_items(query, page, per_page)

        return target_manager._query_get_all(query)
Exemple #9
0
    def relation_instances(self,
                           item,
                           attribute,
                           target_resource,
                           page=None,
                           per_page=None):
        query = getattr(item, attribute)

        if isinstance(query, InstrumentedList):
            if page and per_page:
                return Pagination.from_list(query, page, per_page)
            return query

        target_manager = target_resource.manager
        if isinstance(target_manager, PrincipalMixin):
            query = target_manager._query_filter_read_permission(query)

        if page and per_page:
            return target_manager._query_get_paginated_items(
                query, page, per_page)

        return target_manager._query_get_all(query)
Exemple #10
0
 def relation_instances(self, item, attribute, target_resource, page=None, per_page=None):
     query = getattr(item, attribute)
     if page and per_page:
         return Pagination.from_list(query, page, per_page)
     else:
         return query.all()
Exemple #11
0
 def paginated_instances(self, page, per_page, where=None, sort=None):
     query = self.instances(where, sort)
     # TODO see if this can be better done in one query
     return Pagination(query.paginate(page, per_page), page, per_page,
                       query.count())
Exemple #12
0
 def _paginate(self, items, page, per_page):
     return Pagination.from_list(list(items), page, per_page)
Exemple #13
0
 def _paginate(self, items, page, per_page):
     return Pagination.from_list(list(items), page, per_page)