From 616129ff91ba0b9140546db7e7ef5ff64534dbb5 Mon Sep 17 00:00:00 2001 From: Andy Doan Date: Thu, 3 Dec 2015 11:05:23 -0600 Subject: reports: hide reports URL's when feature not enabled If this feature isn't enabled we should disable the URL's since it just causes our code to crash. Change-Id: I0e12d70236f32cbca5c0bc90e3d64ec1f30c2f8e Reviewed-on: https://review.linaro.org/9431 Reviewed-by: Paul Sokolovsky --- urls.py | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) (limited to 'urls.py') diff --git a/urls.py b/urls.py index 3bc835b..24c24f9 100644 --- a/urls.py +++ b/urls.py @@ -71,21 +71,28 @@ urlpatterns = patterns( 'license_protected_downloads.api.v3.publish'), url(r'^api/v3/link_latest/(?P.*)$', 'license_protected_downloads.api.v3.link_latest'), +) - url(r'^reports/$', - 'license_protected_downloads.views.reports'), - - url(r'^reports/(?P\d{4}\.\d{2})/downloads/', - 'license_protected_downloads.views.reports_month_downloads'), - url(r'^reports/(?P\d{4}\.\d{2})/country/$', - 'license_protected_downloads.views.reports_month_country'), - url(r'^reports/(?P\d{4}\.\d{2})/region/$', - 'license_protected_downloads.views.reports_month_region'), - url(r'^reports/(?P\d{4}\.\d{2})/country/(?P.*)/', - 'license_protected_downloads.views.reports_month_country_details'), - url(r'^reports/(?P\d{4}\.\d{2})/region/(?P.*)/', - 'license_protected_downloads.views.reports_month_region_details'), - +if settings.TRACK_DOWNLOAD_STATS: + urlpatterns += patterns( + '', + url(r'^reports/$', + 'license_protected_downloads.views.reports'), + + url(r'^reports/(?P\d{4}\.\d{2})/downloads/', + 'license_protected_downloads.views.reports_month_downloads'), + url(r'^reports/(?P\d{4}\.\d{2})/country/$', + 'license_protected_downloads.views.reports_month_country'), + url(r'^reports/(?P\d{4}\.\d{2})/region/$', + 'license_protected_downloads.views.reports_month_region'), + url(r'^reports/(?P\d{4}\.\d{2})/country/(?P.*)/', + 'license_protected_downloads.views.reports_month_country_details'), + url(r'^reports/(?P\d{4}\.\d{2})/region/(?P.*)/', + 'license_protected_downloads.views.reports_month_region_details'), + ) + +urlpatterns += patterns( + '', # Catch-all. We always return a file (or try to) if it exists. # This handler does that. url(r'(?P.*)', 'license_protected_downloads.views.file_server'), -- cgit v1.2.3