本文整理汇总了Python中models.Notification.send方法的典型用法代码示例。如果您正苦于以下问题:Python Notification.send方法的具体用法?Python Notification.send怎么用?Python Notification.send使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Notification
的用法示例。
在下文中一共展示了Notification.send方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUpTestData
# 需要导入模块: from models import Notification [as 别名]
# 或者: from models.Notification import send [as 别名]
def setUpTestData(cls):
admin = User.objects.get(pk=1)
group_foo = User.objects.filter(groups__name='group_foo')
staff = User.objects.get_by_natural_key('staff')
cls.admin_user = admin
cls.n2_admin = Notification.send(
[admin],
'test notification to admin',
'fa-info',
Notification.COLOR_DANGER,
url='http://www.google.com/'
)
cls.n2_staff = Notification.send(
[staff],
'test notifications to staff',
'fa-bell',
Notification.COLOR_DANGER,
)
cls.n2_group_foo = Notification.send(
group_foo,
'test notifications to client',
'fa-bell',
Notification.COLOR_WARNING,
''
)
示例2: test_limit_notification
# 需要导入模块: from models import Notification [as 别名]
# 或者: from models.Notification import send [as 别名]
def test_limit_notification(self):
Notification.objects.get(pk=self.n2_admin[0].pk).delete()
for i in range(8):
Notification.send(
[self.admin_user],
'test {}'.format(i),
'fa-info',
Notification.COLOR_DANGER,
url='http://www.google.com/'
)
with self.settings(WEBLINE_NOTIFICATIONS_LIMIT=5):
Notification.objects.filter(
user=self.admin_user
)[0].limit_notification()
all_n_after = Notification.objects.filter(user=self.admin_user)
count = all_n_after.count()
first_content = all_n_after.order_by('send_date')[0].content
last_content = all_n_after.order_by('-send_date')[0].content
self.assertEqual(
count,
5
)
self.assertEqual(
first_content,
'test 3'
)
self.assertEqual(
last_content,
'test 7'
)
with self.settings(WEBLINE_NOTIFICATIONS_LIMIT=False):
Notification.objects.filter(
user=self.admin_user
)[0].limit_notification()
all_n_after = Notification.objects.filter(user=self.admin_user)
count = all_n_after.count()
first_content = all_n_after.order_by('send_date')[0].content
last_content = all_n_after.order_by('-send_date')[0].content
self.assertEqual(
count,
5
)