Lab as a Service 2.0
[laas.git] / src / notifier / views.py
1 ##############################################################################
2 # Copyright (c) 2018 Sawyer Bergeron and others.
3 #
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
9
10 from notifier.models import *
11 from django.shortcuts import render
12
13 def InboxView(request):
14     if request.user.is_authenticated:
15         user = request.user
16     else:
17         return render(request, "dashboard/login.html", {'title': 'Authentication Required'})
18
19     return render(request, "notifier/inbox.html", {'notifier_messages': Notifier.objects.filter(user=user.userprofile)})
20
21
22 def NotificationView(request, notification_id):
23     if notification_id == 0:
24         pass
25     if request.user.is_authenticated:
26         user = request.user
27     else:
28         return render(request, "dashboard/login.html", {'title': 'Authentication Required'})
29
30     notification = Notifier.objects.get(id=notification_id)
31     if not notification.user.user.username == user.username:
32         return render(request, "dashboard/login.html", {'title': 'Access Denied'})
33
34     return render(request, "notifier/notification.html", {'notification': notification})