Simplified the development-mode static files serving, since we're now using the django staticfiles infrastructure.

- Legacy-Id: 9951
This commit is contained in:
Henrik Levkowetz 2015-08-01 15:02:54 +00:00
parent 4dc4c6dc9a
commit ec84efedcd

View file

@ -1,15 +1,15 @@
# Copyright The IETF Trust 2007, 2009, All Rights Reserved # Copyright The IETF Trust 2007, 2009, All Rights Reserved
from django.conf import settings
from django.conf.urls import patterns, include from django.conf.urls import patterns, include
from django.contrib import admin from django.contrib import admin
from django.views.generic import TemplateView from django.views.generic import TemplateView
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
from ietf.liaisons.sitemaps import LiaisonMap from ietf.liaisons.sitemaps import LiaisonMap
from ietf.ipr.sitemaps import IPRMap from ietf.ipr.sitemaps import IPRMap
from ietf import api from ietf import api
from django.conf import settings
admin.autodiscover() admin.autodiscover()
api.autodiscover() api.autodiscover()
@ -72,13 +72,24 @@ for n,a in api._api_list:
(r'^api/v1/', include(a.urls)), (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'): if settings.SERVER_MODE in ('development', 'test'):
urlpatterns += patterns('', urlpatterns += ( staticfiles_urlpatterns()
(r'^(?P<path>(?:images|css|js|test|static)/.*)$', 'django.views.static.serve', {'document_root': settings.STATIC_LOCAL}), + patterns('',
(r'^(?P<path>admin/(?:img|css|js)/.*)$', 'django.views.static.serve', {'document_root': settings.STATIC_LOCAL}), (r'^_test500/$', lambda x: None),
(r'^(?P<path>secretariat/(img|css|js)/.*)$', 'django.views.static.serve', {'document_root': settings.STATIC_LOCAL}), (r'^environment/$', 'ietf.help.views.environment'),
(r'^(?P<path>robots\.txt)$', 'django.views.static.serve', {'document_root': settings.STATIC_LOCAL+"dev/"}), ## maybe preserve some static legacy URLs ?
(r'^_test500/$', lambda x: None), (r'^(?P<path>(?:images|css|js)/.*)$', 'django.views.static.serve', {'document_root': settings.STATIC_ROOT+'ietf/'}),
(r'^environment/$', 'ietf.help.views.environment'), )
) )
# This is needed to serve files which are not handled by collectstatic :
# if settings.SERVER_MODE in ('development', 'test'):
# urlpatterns += patterns('',
# (r'^(?P<path>(?:images|css|js|test|static)/.*)$', 'django.views.static.serve', {'document_root': settings.STATIC_LOCAL}),
# (r'^(?P<path>admin/(?:img|css|js)/.*)$', 'django.views.static.serve', {'document_root': settings.STATIC_LOCAL}),
# (r'^(?P<path>secretariat/(img|css|js)/.*)$', 'django.views.static.serve', {'document_root': settings.STATIC_LOCAL}),
# (r'^(?P<path>robots\.txt)$', 'django.views.static.serve', {'document_root': settings.STATIC_LOCAL+"dev/"}),
# (r'^_test500/$', lambda x: None),
# (r'^environment/$', 'ietf.help.views.environment'),
# )