-
Notifications
You must be signed in to change notification settings - Fork 0
/
views.py
33 lines (29 loc) · 1.03 KB
/
views.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from .models import Membership, Notification
from .forms import LoginForm
from django.http import HttpResponse, HttpResponseRedirect
from django.shortcuts import render
from django.contrib.auth.decorators import login_required, permission_required
from .view_utils import *
def index(request):
if request.user.is_authenticated:
return HttpResponseRedirect('/user_home/') # Redirect after POST
next = '/user_home/'
if 'next' in request.GET:
next = request.GET['next']
return render(request, 'SyllabusTrackerApp/index.html',
{
'title':"Start",
'login_form':LoginForm(),
'target_url':next
})
@login_required
def home(request):
membership = check_membership(request.user)
if isinstance(membership, HttpResponse):
return membership
notifications = Notification.objects.filter(user=request.user)
context = {
'title':"Home",
'notifications':notifications
}
return render(request, 'SyllabusTrackerApp/home.html', context)