django-notifications/notifications/tests/views.py

27 lines
725 B
Python
Raw Normal View History

2016-01-01 02:59:51 +00:00
from django.shortcuts import render
from notifications import notify
import random
2016-01-01 02:59:51 +00:00
def live_tester(request):
2015-12-12 09:41:12 +00:00
notify.send(sender=request.user, recipient=request.user, verb='you loaded the page')
2016-01-01 02:59:51 +00:00
return render(request, 'test_live.html', {
'unread_count': request.user.notifications.unread().count(),
'notifications': request.user.notifications.all()
2016-01-01 02:59:51 +00:00
})
def make_notification(request):
the_notification = random.choice([
'reticulating splines',
'cleaning the car',
'jumping the shark',
'testing the app',
2016-01-01 02:59:51 +00:00
])
2016-01-01 02:59:51 +00:00
notify.send(sender=request.user, recipient=request.user,
verb='you asked for a notification - you are ' + the_notification)