当前位置: 首页>>代码示例>>Python>>正文


Python Feed.get_feeds方法代码示例

本文整理汇总了Python中bootcamp.feeds.models.Feed.get_feeds方法的典型用法代码示例。如果您正苦于以下问题:Python Feed.get_feeds方法的具体用法?Python Feed.get_feeds怎么用?Python Feed.get_feeds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在bootcamp.feeds.models.Feed的用法示例。


在下文中一共展示了Feed.get_feeds方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: load

# 需要导入模块: from bootcamp.feeds.models import Feed [as 别名]
# 或者: from bootcamp.feeds.models.Feed import get_feeds [as 别名]
def load(request):
    from_feed = request.GET.get('from_feed')
    page = request.GET.get('page')
    feed_source = request.GET.get('feed_source')
    all_feeds = Feed.get_feeds(from_feed)
    if feed_source != 'all':
        all_feeds = all_feeds.filter(user__id=feed_source)
    paginator = Paginator(all_feeds, FEEDS_NUM_PAGES)
    try:
        feeds = paginator.page(page)
    except PageNotAnInteger:
        return HttpResponseBadRequest()
    except EmptyPage:
        feeds = []
    html = u''
    csrf_token = unicode(csrf(request)['csrf_token'])
    for feed in feeds:
        html = u'{0}{1}'.format(html,
                                render_to_string('feeds/partial_feed.html',
                                                 {
                                                    'feed': feed,
                                                    'user': request.user,
                                                    'csrf_token': csrf_token
                                                    }))

    return HttpResponse(html)
开发者ID:echopen,项目名称:kit-soft,代码行数:28,代码来源:views.py

示例2: update

# 需要导入模块: from bootcamp.feeds.models import Feed [as 别名]
# 或者: from bootcamp.feeds.models.Feed import get_feeds [as 别名]
def update(request):
    first_feed = request.GET.get('first_feed')
    last_feed = request.GET.get('last_feed')
    feeds = Feed.get_feeds().filter(id__range=(last_feed, first_feed))
    dump = {}
    for feed in feeds:
        dump[feed.pk] = {'likes': feed.likes, 'comments': feed.comments}
    data = json.dumps(dump)
    return HttpResponse(data, mimetype='application/json')
开发者ID:lucasmg,项目名称:bootcamp,代码行数:11,代码来源:views.py

示例3: profile

# 需要导入模块: from bootcamp.feeds.models import Feed [as 别名]
# 或者: from bootcamp.feeds.models.Feed import get_feeds [as 别名]
def profile(request, username):
    page_user = User.objects.get(username=username)
    all_feeds = Feed.get_feeds().filter(user=page_user)
    paginator = Paginator(all_feeds, FEEDS_NUM_PAGES)
    feeds = paginator.page(1)
    from_feed = -1
    if feeds:
        from_feed = feeds[0].id
    return render(
        request, "core/profile.html", {"page_user": page_user, "feeds": feeds, "from_feed": from_feed, "page": 1}
    )
开发者ID:BlastarIndia,项目名称:bootcamp,代码行数:13,代码来源:views.py

示例4: feeds

# 需要导入模块: from bootcamp.feeds.models import Feed [as 别名]
# 或者: from bootcamp.feeds.models.Feed import get_feeds [as 别名]
def feeds(request):
    all_feeds = Feed.get_feeds()
    paginator = Paginator(all_feeds, FEEDS_NUM_PAGES)
    feeds = paginator.page(1)
    from_feed = -1
    if feeds:
        from_feed = feeds[0].id
    return render(request, 'feeds/feeds.html', {
        'feeds': feeds,
        'from_feed': from_feed,
        'page': 1,
        })
开发者ID:echopen,项目名称:kit-soft,代码行数:14,代码来源:views.py

示例5: update

# 需要导入模块: from bootcamp.feeds.models import Feed [as 别名]
# 或者: from bootcamp.feeds.models.Feed import get_feeds [as 别名]
def update(request):
    first_feed = request.GET.get('first_feed')
    last_feed = request.GET.get('last_feed')
    feed_source = request.GET.get('feed_source')
    feeds = Feed.get_feeds().filter(id__range=(last_feed, first_feed))
    if feed_source != 'all':
        feeds = feeds.filter(user__id=feed_source)
    dump = {}
    for feed in feeds:
        dump[feed.pk] = {'likes': feed.likes, 'comments': feed.comments}
    data = json.dumps(dump)
    return HttpResponse(data, content_type='application/json')
开发者ID:echopen,项目名称:kit-soft,代码行数:14,代码来源:views.py

示例6: profile

# 需要导入模块: from bootcamp.feeds.models import Feed [as 别名]
# 或者: from bootcamp.feeds.models.Feed import get_feeds [as 别名]
def profile(request, username):
    page_user = get_object_or_404(User, username=username)
    tag = request.session.get("TRIBE_TAG")
    all_feeds = Feed.get_feeds(tag).filter(user=page_user)
    paginator = Paginator(all_feeds, FEEDS_NUM_PAGES)
    feeds = paginator.page(1)
    from_feed = -1
    if feeds:
        from_feed = feeds[0].id
    return render(
        request, "core/profile.html", {"page_user": page_user, "feeds": feeds, "from_feed": from_feed, "page": 1}
    )
开发者ID:Yihen,项目名称:ibootcamp,代码行数:14,代码来源:views.py

示例7: feeds

# 需要导入模块: from bootcamp.feeds.models import Feed [as 别名]
# 或者: from bootcamp.feeds.models.Feed import get_feeds [as 别名]
def feeds(request):
    tag = request.session.get("TRIBE_TAG")
    all_feeds = Feed.get_feeds(tag)
    paginator = Paginator(all_feeds, FEEDS_NUM_PAGES)
    feeds = paginator.page(1)
    from_feed = -1
    if feeds:
        from_feed = feeds[0].id
    return render(request, 'feeds/feeds.html', {
        'feeds': feeds, 
        'from_feed': from_feed, 
        'page': 1,
        })
开发者ID:Yihen,项目名称:ibootcamp,代码行数:15,代码来源:views.py

示例8: profile

# 需要导入模块: from bootcamp.feeds.models import Feed [as 别名]
# 或者: from bootcamp.feeds.models.Feed import get_feeds [as 别名]
def profile(request, username):
    page_user = get_object_or_404(User, username=username)
    all_feeds = Feed.get_feeds().filter(user=page_user)
    paginator = Paginator(all_feeds, FEEDS_NUM_PAGES)
    feeds = paginator.page(1)
    from_feed = -1
    if feeds:
        from_feed = feeds[0].id
    return render(request, 'core/profile.html', {
        'page_user': page_user,
        'feeds': feeds,
        'from_feed': from_feed,
        'page': 1
        })
开发者ID:Allianzcortex,项目名称:bootcamp,代码行数:16,代码来源:views.py

示例9: profile

# 需要导入模块: from bootcamp.feeds.models import Feed [as 别名]
# 或者: from bootcamp.feeds.models.Feed import get_feeds [as 别名]
def profile(request, username):
    page_user = get_object_or_404(User, username=username)
    all_feeds = Feed.get_feeds().filter(user=page_user)
    paginator = Paginator(all_feeds, FEEDS_NUM_PAGES)
    feeds = paginator.page(1)
    from_feed = -1
    if feeds:  # pragma: no cover
        from_feed = feeds[0].id

    feeds_count = Feed.objects.filter(user=page_user).count()
    article_count = Article.objects.filter(create_user=page_user).count()
    article_comment_count = ArticleComment.objects.filter(
        user=page_user).count()
    question_count = Question.objects.filter(user=page_user).count()
    answer_count = Answer.objects.filter(user=page_user).count()
    activity_count = Activity.objects.filter(user=page_user).count()
    messages_count = Message.objects.filter(
        Q(from_user=page_user) | Q(user=page_user)).count()
    data, datepoints = Activity.daily_activity(page_user)
    data = {
        'page_user': page_user,
        'feeds_count': feeds_count,
        'article_count': article_count,
        'article_comment_count': article_comment_count,
        'question_count': question_count,
        'global_interactions': activity_count + article_comment_count + answer_count + messages_count,  # noqa: E501
        'answer_count': answer_count,
        'bar_data': [
            feeds_count, article_count, article_comment_count, question_count,
            answer_count, activity_count],
        'bar_labels': json.dumps('["Feeds", "Articles", "Comments", "Questions", "Answers", "Activities"]'),  # noqa: E501
        'line_labels': datepoints,
        'line_data': data,
        'feeds': feeds,
        'from_feed': from_feed,
        'page': 1
        }
    return render(request, 'core/profile.html', data)
开发者ID:ghsaheb,项目名称:Bootcamp,代码行数:40,代码来源:views.py

示例10: test_getFeeds_withFromFeed1

# 需要导入模块: from bootcamp.feeds.models import Feed [as 别名]
# 或者: from bootcamp.feeds.models.Feed import get_feeds [as 别名]
 def test_getFeeds_withFromFeed1(self):
     feeds = Feed.get_feeds(self.feed2.id)
     self.assertEquals(len(feeds), 2)
     self.assertTrue(self.feed in feeds)
     self.assertTrue(self.feed2 in feeds)
开发者ID:ghsaheb,项目名称:Bootcamp,代码行数:7,代码来源:test_models.py


注:本文中的bootcamp.feeds.models.Feed.get_feeds方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。