mirror of
https://github.com/TandoorRecipes/recipes.git
synced 2026-01-01 04:10:06 -05:00
space stuff partially working
This commit is contained in:
15
cookbook/helper/scope_middleware.py
Normal file
15
cookbook/helper/scope_middleware.py
Normal file
@@ -0,0 +1,15 @@
|
||||
from django_scopes import scope
|
||||
|
||||
|
||||
class ScopeMiddleware:
|
||||
def __init__(self, get_response):
|
||||
self.get_response = get_response
|
||||
|
||||
def __call__(self, request):
|
||||
if request.user.is_authenticated:
|
||||
request.space = request.user.userpreference.space
|
||||
|
||||
with scope(space=request.space):
|
||||
return self.get_response(request)
|
||||
else:
|
||||
return self.get_response(request)
|
||||
Reference in New Issue
Block a user