1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-16 23:29:49 +00:00

Modify org

This commit is contained in:
xiez
2012-07-26 17:08:31 +08:00
parent 0207e1e162
commit 0132e4e85d
34 changed files with 538 additions and 41 deletions

View File

@@ -0,0 +1,30 @@
from django.core.cache import cache
from django.http import HttpResponseRedirect
from seaserv import get_org_by_url_prefix
from settings import ORG_CACHE_PREFIX
class OrganizationMiddleware(object):
"""
Middleware that add organization info to request when user in organization
context.
"""
def process_request(self, request):
"""
"""
org = cache.get(ORG_CACHE_PREFIX + request.user.username)
request.user.org = org
# full_path = request.get_full_path()
# if full_path.startswith('/organizations/'):
# url_prefix = full_path.split('/')[2]
# org = get_org_by_url_prefix(url_prefix)
# if org:
# request.org = org
return None
def process_response(self, request, response):
return response