Browse Source

add domain auto create middleware, bump version patch

main
Julia Luna 2 years ago
parent
commit
979ce42ccf
Signed by: xenua
GPG Key ID: 6A0C04FA9A7D7582
  1. 12
      scopedsites/middleware.py
  2. 2
      setup.py

12
scopedsites/middleware.py

@ -1,3 +1,4 @@
from django.http import Http404
from django_scopes import scope from django_scopes import scope
from scopedsites.models import Domain from scopedsites.models import Domain
@ -14,3 +15,14 @@ class DomainScopeMiddleware:
response = self.get_response(request) response = self.get_response(request)
return response 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'))

2
setup.py

@ -3,7 +3,7 @@ from setuptools import setup
setup( setup(
name="django_scopedsites", name="django_scopedsites",
packages=["scopedsites", "scopedsites.migrations"], packages=["scopedsites", "scopedsites.migrations"],
version="0.1.0", version="0.1.1",
description="django_scopes x django.contrib.sites", description="django_scopes x django.contrib.sites",
python_requires=">=3.6", python_requires=">=3.6",
install_requires=[ install_requires=[

Loading…
Cancel
Save