當前位置: 首頁>>代碼示例>>Python>>正文


Python MStarredStoryCounts.user_counts方法代碼示例

本文整理匯總了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}
開發者ID:76,項目名稱:NewsBlur,代碼行數:19,代碼來源:views.py

示例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)
開發者ID:jmorahan,項目名稱:NewsBlur,代碼行數:21,代碼來源:views.py


注:本文中的apps.rss_feeds.models.MStarredStoryCounts.user_counts方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。