From ec84efedcdbf23e9f1d7ddb742b7917689769b86 Mon Sep 17 00:00:00 2001 From: Henrik Levkowetz Date: Sat, 1 Aug 2015 15:02:54 +0000 Subject: [PATCH] Simplified the development-mode static files serving, since we're now using the django staticfiles infrastructure. - Legacy-Id: 9951 --- ietf/urls.py | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/ietf/urls.py b/ietf/urls.py index ad41e9939..aaea34236 100644 --- a/ietf/urls.py +++ b/ietf/urls.py @@ -1,15 +1,15 @@ # Copyright The IETF Trust 2007, 2009, All Rights Reserved +from django.conf import settings from django.conf.urls import patterns, include from django.contrib import admin from django.views.generic import TemplateView +from django.contrib.staticfiles.urls import staticfiles_urlpatterns from ietf.liaisons.sitemaps import LiaisonMap from ietf.ipr.sitemaps import IPRMap from ietf import api -from django.conf import settings - admin.autodiscover() api.autodiscover() @@ -72,13 +72,24 @@ for n,a in api._api_list: (r'^api/v1/', include(a.urls)), ) -# This is needed to serve files which are not handled by collectstatic: +# This is needed to serve files during testing if settings.SERVER_MODE in ('development', 'test'): - urlpatterns += patterns('', - (r'^(?P(?:images|css|js|test|static)/.*)$', 'django.views.static.serve', {'document_root': settings.STATIC_LOCAL}), - (r'^(?Padmin/(?:img|css|js)/.*)$', 'django.views.static.serve', {'document_root': settings.STATIC_LOCAL}), - (r'^(?Psecretariat/(img|css|js)/.*)$', 'django.views.static.serve', {'document_root': settings.STATIC_LOCAL}), - (r'^(?Probots\.txt)$', 'django.views.static.serve', {'document_root': settings.STATIC_LOCAL+"dev/"}), - (r'^_test500/$', lambda x: None), - (r'^environment/$', 'ietf.help.views.environment'), - ) + urlpatterns += ( staticfiles_urlpatterns() + + patterns('', + (r'^_test500/$', lambda x: None), + (r'^environment/$', 'ietf.help.views.environment'), + ## maybe preserve some static legacy URLs ? + (r'^(?P(?:images|css|js)/.*)$', 'django.views.static.serve', {'document_root': settings.STATIC_ROOT+'ietf/'}), + ) + ) + +# This is needed to serve files which are not handled by collectstatic : +# if settings.SERVER_MODE in ('development', 'test'): +# urlpatterns += patterns('', +# (r'^(?P(?:images|css|js|test|static)/.*)$', 'django.views.static.serve', {'document_root': settings.STATIC_LOCAL}), +# (r'^(?Padmin/(?:img|css|js)/.*)$', 'django.views.static.serve', {'document_root': settings.STATIC_LOCAL}), +# (r'^(?Psecretariat/(img|css|js)/.*)$', 'django.views.static.serve', {'document_root': settings.STATIC_LOCAL}), +# (r'^(?Probots\.txt)$', 'django.views.static.serve', {'document_root': settings.STATIC_LOCAL+"dev/"}), +# (r'^_test500/$', lambda x: None), +# (r'^environment/$', 'ietf.help.views.environment'), +# )