2023-06-24 00:10:23 +00:00
|
|
|
""" Django notifications views for tests """
|
2018-05-31 04:06:14 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
2018-05-30 04:11:40 +00:00
|
|
|
import random
|
2015-12-12 07:09:20 +00:00
|
|
|
|
2018-05-30 04:11:40 +00:00
|
|
|
from django.contrib.auth.decorators import login_required
|
2023-06-22 21:30:23 +00:00
|
|
|
from django.http import HttpResponse
|
2018-05-30 04:11:40 +00:00
|
|
|
from django.shortcuts import render
|
2023-06-24 00:10:23 +00:00
|
|
|
|
2018-05-31 04:06:14 +00:00
|
|
|
from notifications.signals import notify
|
2015-12-12 07:09:20 +00:00
|
|
|
|
2016-01-01 02:59:51 +00:00
|
|
|
|
2018-05-30 04:11:40 +00:00
|
|
|
@login_required
|
2015-12-12 07:09:20 +00:00
|
|
|
def live_tester(request):
|
2023-06-24 00:10:23 +00:00
|
|
|
notify.send(sender=request.user, recipient=request.user, verb="you loaded the page")
|
2015-12-12 07:09:20 +00:00
|
|
|
|
2023-06-24 00:10:23 +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
|
|
|
|
|
|
|
|
|
2015-12-12 07:09:20 +00:00
|
|
|
def make_notification(request):
|
2023-06-26 23:58:05 +00:00
|
|
|
the_notification = random.choice( # nosec
|
2023-06-24 00:10:23 +00:00
|
|
|
[
|
|
|
|
|
"reticulating splines",
|
|
|
|
|
"cleaning the car",
|
|
|
|
|
"jumping the shark",
|
|
|
|
|
"testing the app",
|
|
|
|
|
"attaching the plumbus",
|
|
|
|
|
]
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
notify.send(
|
|
|
|
|
sender=request.user, recipient=request.user, verb="you asked for a notification - you are " + the_notification
|
|
|
|
|
)
|
2023-06-22 21:30:23 +00:00
|
|
|
|
|
|
|
|
return HttpResponse()
|