diff --git a/debian/changelog b/debian/changelog index bcb9d0082b6..f3bac4be012 100644 --- a/debian/changelog +++ b/debian/changelog @@ -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 diff --git a/openquake/server/settings.py b/openquake/server/settings.py index c7d8aae9f6f..a1a870aa289 100644 --- a/openquake/server/settings.py +++ b/openquake/server/settings.py @@ -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' @@ -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,) diff --git a/openquake/server/urls.py b/openquake/server/urls.py index f6ab5de253c..05d01b641ec 100644 --- a/openquake/server/urls.py +++ b/openquake/server/urls.py @@ -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)))