|
|
|
@ -1,3 +1,4 @@
@@ -1,3 +1,4 @@
|
|
|
|
|
from django.http import Http404 |
|
|
|
|
from django_scopes import scope |
|
|
|
|
|
|
|
|
|
from scopedsites.models import Domain |
|
|
|
@ -14,3 +15,14 @@ class DomainScopeMiddleware:
@@ -14,3 +15,14 @@ class DomainScopeMiddleware:
|
|
|
|
|
response = self.get_response(request) |
|
|
|
|
|
|
|
|
|
return response |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class DomainAutoCreateMiddleware: |
|
|
|
|
def __init__(self, get_response): |
|
|
|
|
self.get_response = get_response |
|
|
|
|
|
|
|
|
|
def __call__(self, request): |
|
|
|
|
try: |
|
|
|
|
Domain.get_from_request(request) |
|
|
|
|
except Http404: |
|
|
|
|
Domain.objects.create(fqdn=request.META.get('HTTP_HOST')) |
|
|
|
|