summaryrefslogtreecommitdiff
path: root/yaksh/middleware/get_notifications.py
diff options
context:
space:
mode:
authoradityacp2020-04-17 16:54:35 +0530
committeradityacp2020-04-17 16:54:35 +0530
commit348f2bc4f727b27abd9878334e886527479d260c (patch)
treeb1652b2c981540a73d0bd87ebca13db4cea22ef0 /yaksh/middleware/get_notifications.py
parent4802a89acef7567c6a8861daab60924fe862367f (diff)
downloadonline_test-348f2bc4f727b27abd9878334e886527479d260c.tar.gz
online_test-348f2bc4f727b27abd9878334e886527479d260c.tar.bz2
online_test-348f2bc4f727b27abd9878334e886527479d260c.zip
Merge monitor, grade user and regrade intosingle dashboard
Diffstat (limited to 'yaksh/middleware/get_notifications.py')
-rw-r--r--yaksh/middleware/get_notifications.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/yaksh/middleware/get_notifications.py b/yaksh/middleware/get_notifications.py
new file mode 100644
index 0000000..d211ad3
--- /dev/null
+++ b/yaksh/middleware/get_notifications.py
@@ -0,0 +1,21 @@
+from notifications_plugin.models import Notification
+
+class NotificationMiddleware(object):
+ """ Middleware to get user's notifications """
+ def __init__(self, get_response):
+ self.get_response = get_response
+
+ def __call__(self, request):
+ # Code to be executed for each request before
+ # the view (and later middleware) are called.
+ user = request.user
+ if user.is_authenticated:
+ notifications = Notification.objects.get_unread_receiver_notifications(
+ user.id
+ ).count()
+ request.custom_notifications = notifications
+ response = self.get_response(request)
+
+ # Code to be executed for each request/response after
+ # the view is called.
+ return response