
Instead of using SCRIPT_NAME / FORCE_SCRIPT_NAME, PATH_INFO and their associated issues, update urls.py to add the subpath to all routes. This allows us to get rid of several hacks: * the uwsgi.ini magic which parses SITE_ROOT, sets SCRIPT_NAME and fixes PATH_INFO * set_script_prefix() in sendalerts * chopping the subpath off an URL in hc.accounts.views._allow_redirect The idea comes from @apollo13 in https://code.djangoproject.com/ticket/35985#comment:5 cc: #1091
32 lines
998 B
Python
32 lines
998 B
Python
from __future__ import annotations
|
|
|
|
from urllib.parse import urlparse
|
|
from django.conf import settings
|
|
from django.contrib import admin
|
|
from django.urls import include, path
|
|
|
|
from hc.accounts import views as accounts_views
|
|
|
|
prefix = ""
|
|
if _path := urlparse(settings.SITE_ROOT).path.lstrip("/"):
|
|
prefix = f"{_path}/"
|
|
|
|
urlpatterns = [
|
|
path(f"{prefix}admin/login/", accounts_views.login),
|
|
path(f"{prefix}admin/", admin.site.urls),
|
|
path(f"{prefix}accounts/", include("hc.accounts.urls")),
|
|
path(f"{prefix}projects/add/", accounts_views.add_project, name="hc-add-project"),
|
|
path(
|
|
f"{prefix}projects/<uuid:code>/settings/",
|
|
accounts_views.project,
|
|
name="hc-project-settings",
|
|
),
|
|
path(
|
|
f"{prefix}projects/<uuid:code>/remove/",
|
|
accounts_views.remove_project,
|
|
name="hc-remove-project",
|
|
),
|
|
path(prefix, include("hc.api.urls")),
|
|
path(prefix, include("hc.front.urls")),
|
|
path(prefix, include("hc.payments.urls")),
|
|
]
|