diff options
author | Justin Choquette <jchoquette@iol.unh.edu> | 2023-06-08 12:46:53 -0400 |
---|---|---|
committer | Justin Choquette <jchoquette@iol.unh.edu> | 2023-07-21 13:17:51 -0400 |
commit | a09db9f287a02873c0226759f8ea444bb304cd59 (patch) | |
tree | 59e744e4b998973a808abbae2d21fbdd6201d829 /src/notifier/views.py | |
parent | 8ddc7e820e120f1dde4e901d3cb6f1dd3f281e65 (diff) |
LaaS 3.0 Almost MVP
Change-Id: Ided9a43cf3088bb58a233dc459711c03f43e11b8
Signed-off-by: Justin Choquette <jchoquette@iol.unh.edu>
Diffstat (limited to 'src/notifier/views.py')
-rw-r--r-- | src/notifier/views.py | 50 |
1 files changed, 0 insertions, 50 deletions
diff --git a/src/notifier/views.py b/src/notifier/views.py index 3a85eda..d65b13a 100644 --- a/src/notifier/views.py +++ b/src/notifier/views.py @@ -6,53 +6,3 @@ # which accompanies this distribution, and is available at # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## - -from django.shortcuts import render -from notifier.models import Notification -from django.db.models import Q - - -def InboxView(request): - if request.user.is_authenticated: - user = request.user - else: - return render(request, "dashboard/login.html", - {'title': 'Authentication Required'}) - - return render(request, - "notifier/inbox.html", - {'unread_notifications': Notification.objects.filter(recipients=user.userprofile).order_by('-id').filter(~Q(read_by=user.userprofile)), - 'read_notifications': Notification.objects.filter(recipients=user.userprofile).order_by('-id').filter(read_by=user.userprofile)}) - - -def NotificationView(request, notification_id): - - if request.user.is_authenticated: - user = request.user - else: - return render(request, - "dashboard/login.html", - {'title': 'Authentication Required'}) - - notification = Notification.objects.get(id=notification_id) - if user.userprofile not in notification.recipients.all(): - return render(request, - "dashboard/login.html", {'title': 'Access Denied'}) - - notification.read_by.add(user.userprofile) - notification.save() - if request.method == 'POST': - if 'delete' in request.POST: - # handle deleting - notification.recipients.remove(user.userprofile) - if not notification.recipients.exists(): - notification.delete() - else: - notification.save() - - if 'unread' in request.POST: - notification.read_by.remove(user.userprofile) - notification.save() - - return render(request, - "notifier/notification.html", {'notification': notification}) |