From 2d5a646940e20b627bec1a950d9227a5d436eb18 Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Sun, 25 Nov 2018 00:32:17 -0400 Subject: [PATCH] URLs: Remove development URLs from main URL file Move the development URL definitions for Rosetta and Debug toolbar to a separate URL file. Convert the single urls.py to a module to allow multiple URL files to be used. Signed-off-by: Roberto Rosario --- mayan/settings/development.py | 2 ++ mayan/urls/__init__.py | 3 +++ mayan/{urls.py => urls/base.py} | 18 +----------------- mayan/urls/development.py | 26 ++++++++++++++++++++++++++ 4 files changed, 32 insertions(+), 17 deletions(-) create mode 100644 mayan/urls/__init__.py rename mayan/{urls.py => urls/base.py} (56%) create mode 100644 mayan/urls/development.py diff --git a/mayan/settings/development.py b/mayan/settings/development.py index 41254180d1..0713e6c78a 100644 --- a/mayan/settings/development.py +++ b/mayan/settings/development.py @@ -19,6 +19,8 @@ if 'django_extensions' not in INSTALLED_APPS: 'django_extensions', ) +ROOT_URLCONF = 'mayan.urls.development' + TEMPLATES[0]['OPTIONS']['loaders'] = ( 'django.template.loaders.filesystem.Loader', 'django.template.loaders.app_directories.Loader', diff --git a/mayan/urls/__init__.py b/mayan/urls/__init__.py new file mode 100644 index 0000000000..a6e360465f --- /dev/null +++ b/mayan/urls/__init__.py @@ -0,0 +1,3 @@ +from __future__ import unicode_literals + +from .base import * # NOQA diff --git a/mayan/urls.py b/mayan/urls/base.py similarity index 56% rename from mayan/urls.py rename to mayan/urls/base.py index 9ddb10ce07..ec05149168 100644 --- a/mayan/urls.py +++ b/mayan/urls/base.py @@ -1,7 +1,6 @@ from __future__ import unicode_literals -from django.conf import settings -from django.conf.urls import include, url +from django.conf.urls import url from django.contrib import admin from drf_yasg.views import get_schema_view @@ -23,18 +22,3 @@ urlpatterns = [ url(r'^swagger/$', schema_view.with_ui('swagger', cache_timeout=None), name='schema-swagger-ui'), url(r'^redoc/$', schema_view.with_ui('redoc', cache_timeout=None), name='schema-redoc'), ] - -if settings.DEBUG: - from django.conf.urls.static import static - urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) - - if 'rosetta' in settings.INSTALLED_APPS: - urlpatterns += [ - url(r'^rosetta/', include('rosetta.urls'), name='rosetta') - ] - - if 'debug_toolbar' in settings.INSTALLED_APPS: - import debug_toolbar - urlpatterns += [ - url(r'^__debug__/', include(debug_toolbar.urls)) - ] diff --git a/mayan/urls/development.py b/mayan/urls/development.py new file mode 100644 index 0000000000..2cab9fec55 --- /dev/null +++ b/mayan/urls/development.py @@ -0,0 +1,26 @@ +from __future__ import unicode_literals + +from django.conf import settings +from django.conf.urls import include, url + +from .base import * # NOQA + +if 'rosetta' in settings.INSTALLED_APPS: + try: + import rosetta # NOQA + except ImportError: + pass + else: + urlpatterns += [ # NOQA + url(r'^rosetta/', include('rosetta.urls'), name='rosetta') + ] + +if 'debug_toolbar' in settings.INSTALLED_APPS: + try: + import debug_toolbar + except ImportError: + pass + else: + urlpatterns += [ # NOQA + url(r'^__debug__/', include(debug_toolbar.urls)) + ]