django-notifications/notifications/tests/views.py

32 lines
909 B
Python
Raw Normal View History

2018-05-31 04:06:14 +00:00
''' Django notifications views for tests '''
# -*- coding: utf-8 -*-
import random
from django.contrib.auth.decorators import login_required
from django.shortcuts import render
2018-05-31 04:06:14 +00:00
from notifications.signals import notify
2016-01-01 02:59:51 +00:00
@login_required
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',
'attaching the plumbus',
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)