From 819309797b419c3bf526c492e898cad215687775 Mon Sep 17 00:00:00 2001 From: JensDiemer Date: Sat, 12 Dec 2020 20:53:18 +0100 Subject: [PATCH] Bugfix urls.py --- conf/ynh_urls.py | 33 +++++++++++++-------------------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/conf/ynh_urls.py b/conf/ynh_urls.py index 1d2efb2..8140ee5 100644 --- a/conf/ynh_urls.py +++ b/conf/ynh_urls.py @@ -1,28 +1,21 @@ from django.conf import settings -from django.conf.urls import include, static, url -from django.conf.urls.i18n import i18n_patterns from django.contrib import admin from django.urls import path from django.views.generic import RedirectView -from for_runners.views.media_files import UserMediaView - -admin.autodiscover() -urlpatterns = i18n_patterns( - path("{settings.PATH_URL}/admin/", admin.site.urls), +# settings.PATH_URL is the $YNH_APP_ARG_PATH +if settings.PATH_URL: + admin.autodiscover() - # FIXME: - # until there is not real CMS pages: redirect to the interesting admin page: - url(r"^{settings.PATH_URL}/$", RedirectView.as_view(pattern_name='admin:index')), -) + urlpatterns = [ + # TODO: + # XXX: Hack - the MEDIA_URL contains the "PATH_URL" already: + # path(settings.MEDIA_URL.lstrip('/'), include('django_tools.serve_media_app.urls')), - -urlpatterns = [ - # TODO: Change from user name to ID? - path('{settings.PATH_URL}/media//', UserMediaView.as_view()), -] + urlpatterns - -if settings.DEBUG: - import debug_toolbar - urlpatterns = [url(r'^__debug__/', include(debug_toolbar.urls))] + urlpatterns + path(f'{settings.PATH_URL}/admin/', admin.site.urls), + path('', RedirectView.as_view(pattern_name='admin:index')), + ] +else: + # Installed to domain root, without a path prefix? + from inventory_project.urls import urlpatterns # noqa