just showing off, don't merge this!
This commit is contained in:
parent
f7938a9dc1
commit
8b988be06e
8 changed files with 7203 additions and 1 deletions
15
githubnetwork/middleware.py
Normal file
15
githubnetwork/middleware.py
Normal file
|
@ -0,0 +1,15 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from django.utils.functional import SimpleLazyObject
|
||||
from githubnetwork.models import GHUser
|
||||
|
||||
|
||||
def get_github_user(request):
|
||||
if not request.user.is_authenticated():
|
||||
return None
|
||||
return GHUser.objects.get(user=request.user)
|
||||
|
||||
|
||||
class GithubUserMiddleware(object):
|
||||
def process_request(self, request):
|
||||
request.gh_user = SimpleLazyObject(lambda: get_github_user(request))
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue