Round out graph views to generate list of user's repos
This commit is contained in:
parent
cc84293480
commit
72e2ae9290
1 changed files with 9 additions and 13 deletions
22
views.py
22
views.py
|
@ -4,19 +4,12 @@ from django.shortcuts import redirect, render_to_response
|
||||||
from django.template import RequestContext
|
from django.template import RequestContext
|
||||||
|
|
||||||
|
|
||||||
class GraphRequestContext(RequestContext):
|
|
||||||
@property
|
|
||||||
def user_repos(self):
|
|
||||||
username = self.request.user.username
|
|
||||||
return self.request.github.get_iter('/users/%s/repos/' % username)
|
|
||||||
|
|
||||||
|
|
||||||
def index(request):
|
def index(request):
|
||||||
'''Index page. Everyone starts here. If the user is logged in (that is, they
|
'''Index page. Everyone starts here. If the user is logged in (that is, they
|
||||||
have a session id) return the follower_graph view. Otherwise, render the
|
have a session id) return the follower_graph view. Otherwise, render the
|
||||||
index page.'''
|
index page.'''
|
||||||
if request.user.is_authenticated():
|
if request.user.is_authenticated():
|
||||||
return redirect('followers')
|
return redirect('graph_followers')
|
||||||
# Set a test cookie. When the user clicks the 'Login' button, test and make
|
# Set a test cookie. When the user clicks the 'Login' button, test and make
|
||||||
# sure this cookie was set properly.
|
# sure this cookie was set properly.
|
||||||
request.session.set_test_cookie()
|
request.session.set_test_cookie()
|
||||||
|
@ -42,12 +35,15 @@ def login(request):
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def graph_followers(request):
|
def graph_followers(request):
|
||||||
return render_to_response('graph_followers.html', GraphRequestContext(request))
|
return render_to_response('graph_followers.html', {
|
||||||
|
'repos': request.github.get_iter('users/%s/repos' % request.user.username)
|
||||||
|
}, RequestContext(request))
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def graph_repo(request, user, repo):
|
def graph_repo(request, user=None, repo=None):
|
||||||
return render_to_response('graph_repo.html', {
|
return render_to_response('graph_repo.html', {
|
||||||
'username': user,
|
'graph_user': user,
|
||||||
'repo': repo,
|
'graph_repo': repo,
|
||||||
}, GraphRequestContext(request))
|
'repos': request.github.get_iter('users/%s/repos' % request.user.username)
|
||||||
|
}, RequestContext(request))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue