當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。