Skip to content

Commit

Permalink
feat: TUP-706 A.1.a. support BLOG_MULTISITE
Browse files Browse the repository at this point in the history
  • Loading branch information
wesleyboar committed Jul 23, 2024
1 parent 17380fb commit a461693
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion taccsite_cms/custom_app_settings.example.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
CUSTOM_APPS = ['apps.custom_example', 'apps.djangocms_blog_customizations']
CUSTOM_MIDDLEWARE = []
CUSTOM_MIDDLEWARE = ['taccsite_cms.middleware.settings.DynamicSiteIdMiddleware']
STATICFILES_DIRS = ()
20 changes: 20 additions & 0 deletions taccsite_cms/middleware/settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from django.conf import settings
from urllib.parse import urlparse
from django.contrib.sites.models import Site

class DynamicSiteIdMiddleware:
def __init__(self, get_response):
self.get_response = get_response

def __call__(self, request):
# One-time configuration and initialization.
try:
current_site = Site.objects.get(domain=request.get_host())
except Site.DoesNotExist:
current_site = Site.objects.get(id=settings.DEFAULT_SITE_ID)

request.current_site = current_site
settings.SITE_ID = current_site.id

response = self.get_response(request)
return response
4 changes: 4 additions & 0 deletions taccsite_cms/settings_local.example.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,7 @@
# To disable the Core-Portal integration
PORTAL_IS_TACC_CORE_PORTAL = False
PORTAL_HAS_LOGIN = False

# To allow login in unique situations
# FAQ: If `BLOG_MULTISITE = True`, set `SESSION_COOKIE_SECURE=False` to be able to log in to CMS Admin at different domain (e.g. 0.0.0.0)
SESSION_COOKIE_SECURE = False

0 comments on commit a461693

Please sign in to comment.