本文整理汇总了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')
示例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)