本文整理匯總了Python中bootcamp.activities.models.Activity.activity_type方法的典型用法代碼示例。如果您正苦於以下問題:Python Activity.activity_type方法的具體用法?Python Activity.activity_type怎麽用?Python Activity.activity_type使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類bootcamp.activities.models.Activity
的用法示例。
在下文中一共展示了Activity.activity_type方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: setUp
# 需要導入模塊: from bootcamp.activities.models import Activity [as 別名]
# 或者: from bootcamp.activities.models.Activity import activity_type [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()