2012-08-17 20:41:55 -07:00
|
|
|
from django.contrib.auth.decorators import login_required
|
|
|
|
from django.shortcuts import redirect, render_to_response
|
2012-08-17 20:26:22 -07:00
|
|
|
|
|
|
|
|
|
|
|
def index(request):
|
2012-08-17 20:41:55 -07:00
|
|
|
'''Index page. Everyone starts here. If the user is logged in (that is, they
|
2012-08-17 20:44:27 -07:00
|
|
|
have a session id) return the follower_graph view. Otherwise, render the
|
|
|
|
index page.'''
|
2012-08-17 20:41:55 -07:00
|
|
|
if request.method == 'POST':
|
|
|
|
request.session.set_test_cookie()
|
|
|
|
return redirect('login')
|
|
|
|
if 'sessionid' in request.session:
|
|
|
|
return follower_graph(request)
|
2012-08-17 20:26:22 -07:00
|
|
|
return render_to_response('login.html')
|
2012-08-17 20:41:55 -07:00
|
|
|
|
|
|
|
|
2012-08-17 20:44:27 -07:00
|
|
|
def login(request):
|
|
|
|
'''Do a quick check to make sure cookies are enabled. If so, redirect to
|
|
|
|
GitHub so the user can login.'''
|
2012-08-17 20:41:55 -07:00
|
|
|
if request.session.test_cookie_worked():
|
|
|
|
request.session.delete_test_cookie()
|
|
|
|
return redirect('/login/github/')
|
|
|
|
else:
|
|
|
|
return render_to_response('login.html')
|
|
|
|
|
|
|
|
|
|
|
|
@login_required
|
|
|
|
def follower_graph(request):
|
|
|
|
return 'Hello!'
|