本文整理汇总了Python中bootcamp.activities.models.Activity.user方法的典型用法代码示例。如果您正苦于以下问题:Python Activity.user方法的具体用法?Python Activity.user怎么用?Python Activity.user使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bootcamp.activities.models.Activity
的用法示例。
在下文中一共展示了Activity.user方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
# 需要导入模块: from bootcamp.activities.models import Activity [as 别名]
# 或者: from bootcamp.activities.models.Activity import user [as 别名]
def setUp(self):
# creates a fictif user
u = User()
u.username = "testusername"
u.password = "secretpassword"
u.save()
# create an activity related to that user
activity = Activity()
activity.user = u
activity.activity_type = "Favorite"
activity.date = timezone.now()
# check we can save it to the database
activity.save()
# creates two fictif users
u1 = User()
u1.username = "testusername1"
u1.password = "secretpassword1"
u1.save()
u2 = User()
u2.username = "testusername2"
u2.password = "secretpassword2"
u2.save()
# create one notification for each type of notification
# Liked
notifL = Notification()
notifL.from_user = u1
notifL.to_user = u2
notifL.date = timezone.now()
notifL.notification_type = 'Liked' # this is a like
# save it to the database
notifL.save()
# Commented
notifC = Notification()
notifC.from_user = u1
notifC.to_user = u2
notifC.date = timezone.now()
notifC.notification_type = 'Commented'
# save it to the database
notifC.save()
# Favorited
notifF = Notification()
notifF.from_user = u1
notifF.to_user = u2
notifF.date = timezone.now()
notifF.notification_type = 'Favorited'
# save it to the database
notifF.save()
# Answered
notifA = Notification()
notifA.from_user = u1
notifA.to_user = u2
notifA.date = timezone.now()
notifA.notification_type = 'Answered'
# save it to the database
notifA.save()
# Accepted answer
notifW = Notification()
notifW.from_user = u1
notifW.to_user = u2
notifW.date = timezone.now()
notifW.notification_type = 'Accepted Answer'
# save it to the database
notifW.save()
# Edited article
notifE = Notification()
notifE.from_user = u1
notifE.to_user = u2
notifE.date = timezone.now()
notifE.notification_type = 'Edited Article'
# save it to the database
notifE.save()
# Also commented
notifS = Notification()
notifS.from_user = u1
notifS.to_user = u2
notifS.date = timezone.now()
notifS.notification_type = 'Also Commented'
# save it to the database
notifS.save()