-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix login paths for admin, redirect /admin to admin subdomain
- Loading branch information
1 parent
2a6cbbf
commit 2c3e571
Showing
5 changed files
with
34 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,18 @@ | ||
from __future__ import absolute_import, unicode_literals | ||
|
||
from django.conf.urls import include, url | ||
|
||
from wagtail.core import urls as wagtail_urls | ||
from wagtail.admin import urls as wagtailadmin_urls | ||
from django.urls import path, include | ||
from moore.urls import urlpatterns as base_urlpatterns | ||
|
||
# Use the same `urlpatterns` as other domains as the base | ||
urlpatterns = base_urlpatterns.copy() | ||
|
||
urlpatterns = [ | ||
path(r'', include(wagtailadmin_urls)), | ||
] | ||
# Append `wagtailadmin_urls` before `wagtail_urls` | ||
for index, pattern in enumerate(urlpatterns): | ||
if hasattr(pattern, 'url_patterns'): | ||
if wagtail_urls.urlpatterns == pattern.url_patterns: | ||
# Insert the new_pattern before the wagtail include | ||
urlpatterns.insert(index, url(r'', include(wagtailadmin_urls))) | ||
break |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from django.conf import settings | ||
from django_hosts.resolvers import reverse_host | ||
from django.http import HttpResponseRedirect | ||
|
||
|
||
def redirect_admin(request, path): | ||
protocol = 'https' if request.is_secure() else 'http' | ||
host = reverse_host(host='admin') | ||
if getattr(settings, 'HOST_PORT', None): | ||
host = f"{host}:{settings.HOST_PORT}" | ||
return HttpResponseRedirect(f'{protocol}://{host}/{path}') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,6 +40,7 @@ | |
BASE_URL = 'https://utn.se' | ||
|
||
ALLOWED_HOSTS = ['.utn.se', '.utnarm.se'] | ||
PARENT_HOST = 'utn.se' | ||
|
||
# Email settings | ||
DEFAULT_FROM_EMAIL = '[email protected]' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters