本文整理汇总了Python中notifications.models.Notification.all方法的典型用法代码示例。如果您正苦于以下问题:Python Notification.all方法的具体用法?Python Notification.all怎么用?Python Notification.all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类notifications.models.Notification
的用法示例。
在下文中一共展示了Notification.all方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testBasic
# 需要导入模块: from notifications.models import Notification [as 别名]
# 或者: from notifications.models.Notification import all [as 别名]
def testBasic(self):
c = Client()
assert not Error.all().count()
c.post(reverse("error-post"), test_data)
assert test_data["priority"] < 5, test_data["priority"]
assert Error.all().count() == 1
assert Notification.all().count() == 1
c.post(reverse("error-post"), test_data)
assert test_data["priority"] < 5, test_data["priority"]
assert Error.all().count() == 2
assert Notification.all().count() == 2
示例2: notifications_send
# 需要导入模块: from notifications.models import Notification [as 别名]
# 或者: from notifications.models.Notification import all [as 别名]
def notifications_send(request):
log("Firing cron: notifications_send")
notifications = Notification.all().filter("type = ", "Error").filter("tried = ", False)
# batch up the notifications for the user
holders = {}
for notif in notifications:
for user in notif.user_list():
key = str(user.key())
if key not in holders:
holder = Holder()
holder.user = user
holders[key] = holder
holders[key].objs.append(notif.notifier())
holders[key].notifs.append(notif)
for user_id, holder in holders.items():
try:
send_error_email(holder)
for notification in holder.notifs:
notification.tried = True
notification.completed = True
notification.save()
except:
info = sys.exc_info()
data = "%s, %s" % (info[0], info[1])
for notification in holder.notifs:
notification.tried = True
notification.completed = True
notification.error_msg = data
notification.save()
return render_plain("Cron job completed")
示例3: test_achievement_notification_get_all_asc
# 需要导入模块: from notifications.models import Notification [as 别名]
# 或者: from notifications.models.Notification import all [as 别名]
def test_achievement_notification_get_all_asc(self):
#with three we have enought to test
achieves = Achievement.objects.all()
user = User.objects.get(id=1)
r = get_redis_connection()
a_len = len(achieves)
for i in achieves:
notif = AchievementNotification(achievement=i, user=user)
time.sleep(1)
if random.randrange(100) % 2:
key = Notification.STORE_KEY_UNREAD_FORMAT.format(user.id)
else:
key = Notification.STORE_KEY_READ_FORMAT.format(user.id)
r.zadd(key, notif.date, notif.to_json())
# Get notifications
res = Notification.all(user, desc=False)
self.assertEquals(a_len, len(res))
for i in range(len(res)):
before = achieves[i]
after = res[i]
self.assertEquals(before.id, after.achievement_id)
示例4: notifications_cleanup
# 需要导入模块: from notifications.models import Notification [as 别名]
# 或者: from notifications.models.Notification import all [as 别名]
def notifications_cleanup(request):
log("Firing cron: notifications_cleanup")
expired = datetime.today() - timedelta(days=7)
queryset = Notification.all().filter("tried = ", True).filter("timestamp < ", expired)
for notification in queryset:
notification.delete()
return render_plain("Cron job completed")
示例5: testNoNotification
# 需要导入模块: from notifications.models import Notification [as 别名]
# 或者: from notifications.models.Notification import all [as 别名]
def testNoNotification(self):
c = Client()
assert not Error.all().count()
data = test_data.copy()
data["priority"] = 6
c.post(reverse("error-post"), data)
assert data["priority"] > 5, data["priority"]
assert Error.all().count() == 1
assert Notification.all().count() == 0
示例6: notifications_list
# 需要导入模块: from notifications.models import Notification [as 别名]
# 或者: from notifications.models.Notification import all [as 别名]
def notifications_list(request):
queryset = Notification.all().order("-timestamp")
# this number doesn't need to be high and its quite an expensive
# page to generate
paginated = Paginator(queryset, 10)
page = get_page(request, paginated)
return direct_to_template(request, "notification_list.html", extra_context={
"page": page,
"nav": {"selected": "notifications"}
})
示例7: testProfile
# 需要导入模块: from notifications.models import Notification [as 别名]
# 或者: from notifications.models.Notification import all [as 别名]
def testProfile(self):
user = create_user()
c = Client()
data = test_data.copy()
data["priority"] = 6
c.post(reverse("error-post"), data)
assert Notification.all().count() == 0, Notification.all().count()
data["priority"] = 5
c.post(reverse("error-post"), data)
assert Notification.all().count() == 1
profile = get_profile(user)
profile.notification = 8
data["priority"] = 5
c.post(reverse("error-post"), data)
assert Notification.all().count() == 2
data["priority"] = 8
c.post(reverse("error-post"), data)
assert Notification.all().count() == 2
data["priority"] = 9
c.post(reverse("error-post"), data)
assert Notification.all().count() == 2
示例8: testIssueAndErrorNotification
# 需要导入模块: from notifications.models import Notification [as 别名]
# 或者: from notifications.models.Notification import all [as 别名]
def testIssueAndErrorNotification(self):
user = create_user()
issue = Issue()
issue.description = "This is a test"
issue.save()
assert Issue.all().count() == 1
c = Client()
c.post(reverse("error-post"), test_data)
#assert Notification.all().count() == 2
# this would be 2 when issues are turned on
assert Notification.all().count() == 1
c = Client()
res = c.get(reverse("notification-send"))
self.assertEquals(len(mail.outbox), 1)
示例9: testNotificationNoUsers
# 需要导入模块: from notifications.models import Notification [as 别名]
# 或者: from notifications.models.Notification import all [as 别名]
def testNotificationNoUsers(self):
c = Client()
c.post(reverse("error-post"), test_data)
assert Notification.all().count() == 0
示例10: setUp
# 需要导入模块: from notifications.models import Notification [as 别名]
# 或者: from notifications.models.Notification import all [as 别名]
def setUp(self):
for error in Error.all(): error.delete()
for notification in Notification.all(): notification.delete()
for user in AppUser.all(): user.delete()
for issue in Issue.all(): issue.delete()
示例11: setUp
# 需要导入模块: from notifications.models import Notification [as 别名]
# 或者: from notifications.models.Notification import all [as 别名]
def setUp(self):
for error in Error.all(): error.delete()
for notification in Notification.all(): notification.delete()