Skip to content

Allow free mapping between standalone apps and their url path prefix. #10535

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[Matteo Nastasi]
* Allow free mapping between standlone apps and their url path prefix
(regardless of their name)
[Claudia Mascandola]
* Added GMPEs of ambraseys_1996 and sabetta_pugliese_1996

Expand Down
12 changes: 12 additions & 0 deletions openquake/server/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,20 @@
from openquake.baselib import config
from openquake.commonlib import datastore

# optionally overridden in local_settings.py
STANDALONE_APP_NAME_MAP = {}
try:
from openquakeplatform.settings import STANDALONE, STANDALONE_APPS
except ImportError:
STANDALONE = False
STANDALONE_APPS = ()

try:
from openquakeplatform.settings import INSTALLED_APPS as OQP_INSTALLED_APPS
except ImportError:
OQP_INSTALLED_APPS = []


DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
WEBUI_USER = 'openquake'

Expand Down Expand Up @@ -409,3 +417,7 @@ def filter(self, record):
{'NAME': 'django.contrib.auth.password_validation.'
'NumericPasswordValidator', },
]

for app in OQP_INSTALLED_APPS:
if app not in INSTALLED_APPS:
INSTALLED_APPS += (app,)
8 changes: 6 additions & 2 deletions openquake/server/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,12 @@
name="impact_get_shakemap_versions"),
]

for app in settings.STANDALONE_APPS:
app_name = app.split('_')[1]
for app_full in settings.STANDALONE_APPS:
app = app_full.split('.')[0]
if app in settings.STANDALONE_APP_NAME_MAP:
app_name = settings.STANDALONE_APP_NAME_MAP[app]
else:
app_name = app.split('_')[1]
urlpatterns.append(re_path(r'^%s/' % app_name, include(
'%s.urls' % app, namespace='%s' % app_name)))

Expand Down