Permalink
Browse files

Added middleware to manage authentication and graphing JS

  • Loading branch information...
1 parent 1d92a63 commit 3e479ceadff459de09e925b4c0ceb030b5d1f7b9 @thedjpetersen committed Jun 15, 2011
View
@@ -6,7 +6,6 @@
def index(request):
if 'regclass' in request.session:
-
return HttpResponseRedirect('/main')
return render_to_response('index.html', {'no_show_nav': 1})
@@ -32,15 +31,10 @@ def logout(request):
return HttpResponseRedirect('/')
def main(request):
- if not 'regclass' in request.session:
- return HttpResponseRedirect('/')
regclass = request.session['regclass']
return render_to_response('main.html')
def scheduler(request):
- if not 'regclass' in request.session:
- return HttpResponseRedirect('/')
-
if request.method == 'GET':
return render_to_response('scheduler/index.html')
regclass = request.session['regclass']
@@ -57,9 +51,6 @@ def scheduler(request):
return render_to_response('scheduler/index.html', {'combinations':combinations, 'json':combinations_json, 'range':range(24), 'classes_possible':classes_possible})
def planner(request):
- if not 'regclass' in request.session:
- return HttpResponseRedirect('/')
-
regclass = request.session['regclass']
required_courses = []
View
No changes.
@@ -0,0 +1,9 @@
+from django.http import HttpResponseRedirect
+
+class AuthenticationMiddleware(object):
+
+ def process_request(self, request):
+ if len(request.path_info)>1:
+ if 'regclass' not in request.session:
+ return HttpResponseRedirect('/')
+ return None
View
@@ -6,9 +6,6 @@
# Create your views here.
def index(request):
- if not 'regclass' in request.session:
- return HttpResponseRedirect('/')
-
regclass = request.session['regclass']
schedule = regclass.schedule.current_classes
schedule_json = json.dumps(schedule)
@@ -22,9 +19,6 @@ def index(request):
return render_to_response('schedule/index.html', {'schedule':schedule, 'range':range(24), 'json':schedule_json, 'current_term': True})
def next_term(request):
- if not 'regclass' in request.session:
- return HttpResponseRedirect('/')
-
regclass = request.session['regclass']
schedule = regclass.next_schedule.current_classes
schedule_json = json.dumps(schedule)
View
@@ -5,9 +5,6 @@
import reglib
def index(request):
- if not 'regclass' in request.session:
- return HttpResponseRedirect('/')
-
if request.method == 'GET':
return render_to_response('scheduler/index.html')
View
@@ -65,6 +65,7 @@
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
+ 'reggit.middleware.authentication.AuthenticationMiddleware'
)
ROOT_URLCONF = 'reggit.urls'

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -6,9 +6,6 @@
# Create your views here.
def index(request):
- if not 'regclass' in request.session:
- return HttpResponseRedirect('/')
-
regclass = request.session['regclass']
transcript = regclass.transcript.sort_by_term()
return render_to_response('transcript/index.html', {'transcript':transcript, 'credits': regclass.transcript.credits, 'gpa': regclass.transcript.gpa})

0 comments on commit 3e479ce

Please sign in to comment.