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


Python Activity.daily_activity方法代码示例

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


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

示例1: test_activity_daily_statistic

# 需要导入模块: from bootcamp.activities.models import Activity [as 别名]
# 或者: from bootcamp.activities.models.Activity import daily_activity [as 别名]
 def test_activity_daily_statistic(self):
     activity_one = Activity.objects.create(
         user=self.user,
         activity_type='L'
     )
     activity_two = Activity.objects.create(
         user=self.user,
         activity_type='L'
     )
     activity_three = Activity.objects.create(
         user=self.user,
         activity_type='L'
     )
     self.assertTrue(isinstance(activity_one, Activity))
     self.assertTrue(isinstance(activity_two, Activity))
     self.assertTrue(isinstance(activity_three, Activity))
     self.assertEqual(Activity.daily_activity(self.user), ('[{}]'.format(
         Activity.objects.all().count()), '["{}"]'.format(
             activity_one.date.date())))
     self.assertEqual(Activity.daily_activity(self.other_user)[0], '0')
开发者ID:ghsaheb,项目名称:Bootcamp,代码行数:22,代码来源:test_models.py

示例2: profile

# 需要导入模块: from bootcamp.activities.models import Activity [as 别名]
# 或者: from bootcamp.activities.models.Activity import daily_activity [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


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