本文整理汇总了Python中apps.rss_feeds.models.MStarredStoryCounts.user_counts方法的典型用法代码示例。如果您正苦于以下问题:Python MStarredStoryCounts.user_counts方法的具体用法?Python MStarredStoryCounts.user_counts怎么用?Python MStarredStoryCounts.user_counts使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类apps.rss_feeds.models.MStarredStoryCounts
的用法示例。
在下文中一共展示了MStarredStoryCounts.user_counts方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: api_saved_tag_list
# 需要导入模块: from apps.rss_feeds.models import MStarredStoryCounts [as 别名]
# 或者: from apps.rss_feeds.models.MStarredStoryCounts import user_counts [as 别名]
def api_saved_tag_list(request):
user = request.user
starred_counts, starred_count = MStarredStoryCounts.user_counts(user.pk, include_total=True)
tags = []
for tag in starred_counts:
if tag['tag'] == "": continue
tags.append(dict(label="%s (%s %s)" % (tag['tag'], tag['count'],
'story' if tag['count'] == 1 else 'stories'),
value=tag['tag']))
tags = sorted(tags, key=lambda t: t['value'].lower())
catchall = dict(label="All Saved Stories (%s %s)" % (starred_count,
'story' if starred_count == 1 else 'stories'),
value="all")
tags.insert(0, catchall)
return {"data": tags}
示例2: delete_starred_stories
# 需要导入模块: from apps.rss_feeds.models import MStarredStoryCounts [as 别名]
# 或者: from apps.rss_feeds.models.MStarredStoryCounts import user_counts [as 别名]
def delete_starred_stories(request):
timestamp = request.POST.get("timestamp", None)
if timestamp:
delete_date = datetime.datetime.fromtimestamp(int(timestamp))
else:
delete_date = datetime.datetime.now()
starred_stories = MStarredStory.objects.filter(user_id=request.user.pk, starred_date__lte=delete_date)
stories_deleted = starred_stories.count()
starred_stories.delete()
MStarredStoryCounts.count_for_user(request.user.pk, total_only=True)
starred_counts, starred_count = MStarredStoryCounts.user_counts(request.user.pk, include_total=True)
logging.user(
request.user,
"~BC~FRDeleting %s/%s starred stories (%s)" % (stories_deleted, stories_deleted + starred_count, delete_date),
)
return dict(code=1, stories_deleted=stories_deleted, starred_counts=starred_counts, starred_count=starred_count)