def _process(self):
     query = (Category.query.filter(
         Category.title_matches(request.args['term']),
         ~Category.is_deleted).options(undefer('chain_titles')).order_by(
             Category.title))
     results = [{
         'title': category.title,
         'path': category.chain_titles[1:-1],
         'url': unicode(category.url)
     } for category in query.limit(7)]
     return jsonify(success=True, results=results, count=query.count())
Пример #2
0
 def _process(self):
     query = (Category.query
              .filter(Category.title_matches(request.args['term']),
                      ~Category.is_deleted)
              .options(undefer('chain_titles'))
              .order_by(Category.title))
     results = [{
         'title': category.title,
         'path': category.chain_titles[1:-1],
         'url': unicode(category.url)
     } for category in query.limit(7)]
     return jsonify(success=True, results=results, count=query.count())
Пример #3
0
    def search_categories(self, q, user, page, category_id,
                          admin_override_enabled):
        query = Category.query if not category_id else Category.get(
            category_id).deep_children_query

        query = (query.filter(Category.title_matches(q),
                              ~Category.is_deleted).options(
                                  undefer('chain'),
                                  undefer(Category.effective_protection_mode),
                                  subqueryload(Category.acl_entries)))

        objs, pagenav = self._paginate(query, page, Category.id, user,
                                       admin_override_enabled)
        res = DetailedCategorySchema(many=True).dump(objs)
        return pagenav, CategoryResultSchema(many=True).load(res)