mirror of
https://github.com/TandoorRecipes/recipes.git
synced 2025-12-24 02:39:20 -05:00
16 lines
430 B
Python
16 lines
430 B
Python
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)
|