本文整理匯總了Python中web.controllers.ArticleController.count方法的典型用法代碼示例。如果您正苦於以下問題:Python ArticleController.count方法的具體用法?Python ArticleController.count怎麽用?Python ArticleController.count使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類web.controllers.ArticleController
的用法示例。
在下文中一共展示了ArticleController.count方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: user_stream
# 需要導入模塊: from web.controllers import ArticleController [as 別名]
# 或者: from web.controllers.ArticleController import count [as 別名]
def user_stream(per_page, nickname=None):
"""
Display the stream of a user (list of articles of public feed).
"""
user_contr = UserController()
user = user_contr.get(nickname=nickname)
if not user.is_public_profile:
if current_user.is_authenticated and current_user.id == user.id:
flash(gettext('You must set your profile to public.'), 'info')
return redirect(url_for('user.profile'))
category_id = int(request.args.get('category_id', 0))
category = CategoryController().read(id=category_id).first()
# Load the public feeds
filters = {}
filters['private'] = False
if category_id:
filters['category_id'] = category_id
feeds = FeedController().read(**filters).all()
# Re-initializes the filters to load the articles
filters = {}
filters['feed_id__in'] = [feed.id for feed in feeds]
if category:
filters['category_id'] = category_id
articles = ArticleController(user.id).read_light(**filters)
# Server-side pagination
page, per_page, offset = get_page_args(per_page_parameter='per_page')
pagination = Pagination(page=page, total=articles.count(),
css_framework='bootstrap3',
search=False, record_name='articles',
per_page=per_page)
return render_template('user_stream.html', user=user,
articles=articles.offset(offset).limit(per_page),
category=category,
pagination=pagination)