diff --git a/horizon/base.py b/horizon/base.py index 6fac4ce8f5..9e60f10ad4 100644 --- a/horizon/base.py +++ b/horizon/base.py @@ -89,6 +89,24 @@ def access_cached(func): return inner +def _wrapped_include(arg): + """Convert the old 3-tuple arg for include() into the new format. + + The argument "arg" should be a tuple with 3 elements: + (pattern_list, app_namespace, instance_namespace) + + Prior to Django 2.0, django.urls.conf.include() accepts 3-tuple arg + (urlconf, namespace, app_name), but it was droppped in Django 2.0. + This function is used to convert the older 3-tuple used in horizon code + into the new format where namespace needs to be passed as the second arg. + + For more details, see + https://docs.djangoproject.com/en/2.0/releases/1.9/#passing-a-3-tuple-or-an-app-name-to-include + """ + pattern_list, app_namespace, instance_namespace = arg + return include((pattern_list, app_namespace), namespace=instance_namespace) + + class NotRegistered(Exception): pass @@ -544,12 +562,13 @@ class Dashboard(Registry, HorizonComponent): continue url_slug = panel.slug.replace('.', '/') urlpatterns.append(url(r'^%s/' % url_slug, - include(panel._decorated_urls))) + _wrapped_include(panel._decorated_urls))) # Now the default view, which should come last if not default_panel: raise NotRegistered('The default panel "%s" is not registered.' % self.default_panel) - urlpatterns.append(url(r'', include(default_panel._decorated_urls))) + urlpatterns.append( + url(r'', _wrapped_include(default_panel._decorated_urls))) # Require login if not public. if not self.public: @@ -867,7 +886,7 @@ class Site(Registry, HorizonComponent): # Compile the dynamic urlconf. for dash in self._registry.values(): urlpatterns.append(url(r'^%s/' % dash.slug, - include(dash._decorated_urls))) + _wrapped_include(dash._decorated_urls))) # add URL for ngdetails views = import_module('horizon.browsers.views') diff --git a/horizon/site_urls.py b/horizon/site_urls.py index ab16880c83..f896831e82 100644 --- a/horizon/site_urls.py +++ b/horizon/site_urls.py @@ -32,7 +32,7 @@ urlpatterns = [ # Client-side i18n URLconf. urlpatterns.extend([ url(r'^i18n/js/(?P\S+?)/$', - i18n.javascript_catalog, + i18n.JavaScriptCatalog.as_view(), name='jsi18n'), url(r'^i18n/setlang/$', i18n.set_language, diff --git a/horizon/test/urls.py b/horizon/test/urls.py index 27965425d5..9d9e84dfb5 100644 --- a/horizon/test/urls.py +++ b/horizon/test/urls.py @@ -27,11 +27,12 @@ from django.contrib.staticfiles.urls import staticfiles_urlpatterns from django.views.generic import TemplateView import horizon +import horizon.base from horizon.test.jasmine import jasmine urlpatterns = [ - url(r'', include(horizon.urls)), + url(r'', horizon.base._wrapped_include(horizon.urls)), url(r"auth/login/", views.login, {'template_name': "auth/login.html"}, name='login'), url(r'auth/', include('django.contrib.auth.urls')), diff --git a/openstack_dashboard/dashboards/admin/hypervisors/urls.py b/openstack_dashboard/dashboards/admin/hypervisors/urls.py index 136a3cfdc9..f487fb6da5 100644 --- a/openstack_dashboard/dashboards/admin/hypervisors/urls.py +++ b/openstack_dashboard/dashboards/admin/hypervisors/urls.py @@ -25,5 +25,5 @@ urlpatterns = [ views.AdminDetailView.as_view(), name='detail'), url(r'^$', views.AdminIndexView.as_view(), name='index'), - url(r'', include(compute_urls, namespace='compute')), + url(r'', include((compute_urls, 'compute'))), ] diff --git a/openstack_dashboard/dashboards/admin/networks/urls.py b/openstack_dashboard/dashboards/admin/networks/urls.py index cdd51afd08..7535491323 100644 --- a/openstack_dashboard/dashboards/admin/networks/urls.py +++ b/openstack_dashboard/dashboards/admin/networks/urls.py @@ -53,6 +53,6 @@ urlpatterns = [ url(r'^(?P[^/]+)/ports/(?P[^/]+)/update$', port_views.UpdateView.as_view(), name='editport'), - url(r'^subnets/', include(subnet_urls, namespace='subnets')), - url(r'^ports/', include(port_urls, namespace='ports')), + url(r'^subnets/', include((subnet_urls, 'subnets'))), + url(r'^ports/', include((port_urls, 'ports'))), ] diff --git a/openstack_dashboard/dashboards/admin/volume_types/urls.py b/openstack_dashboard/dashboards/admin/volume_types/urls.py index 0e8cadf04c..43433cb386 100644 --- a/openstack_dashboard/dashboards/admin/volume_types/urls.py +++ b/openstack_dashboard/dashboards/admin/volume_types/urls.py @@ -37,7 +37,7 @@ urlpatterns = [ views.EditQosSpecConsumerView.as_view(), name='edit_qos_spec_consumer'), url(r'^(?P[^/]+)/extras/', - include(extras_urls, namespace='extras')), + include((extras_urls, 'extras'))), url(r'^(?P[^/]+)/create_type_encryption/$', views.CreateVolumeTypeEncryptionView.as_view(), name='create_type_encryption'), @@ -48,7 +48,7 @@ urlpatterns = [ views.VolumeTypeEncryptionDetailView.as_view(), name='type_encryption_detail'), url(r'^qos_specs/', - include(qos_specs_urls, namespace='qos_specs')), + include((qos_specs_urls, 'qos_specs'))), url(r'^(?P[^/]+)/edit_access/$', views.EditAccessView.as_view(), name='edit_access'), ] diff --git a/openstack_dashboard/dashboards/identity/identity_providers/urls.py b/openstack_dashboard/dashboards/identity/identity_providers/urls.py index 8ea262be40..71912e15ef 100644 --- a/openstack_dashboard/dashboards/identity/identity_providers/urls.py +++ b/openstack_dashboard/dashboards/identity/identity_providers/urls.py @@ -32,5 +32,5 @@ urlpatterns = [ views.UpdateView.as_view(), name='update'), url(r'^register/$', views.RegisterView.as_view(), name='register'), url(r'(?P[^/]+)/protocols/', - include(protocol_urls, namespace='protocols')), + include((protocol_urls, 'protocols'))), ] diff --git a/openstack_dashboard/dashboards/project/images/urls.py b/openstack_dashboard/dashboards/project/images/urls.py index 88ae3e05aa..e4d25f2b99 100644 --- a/openstack_dashboard/dashboards/project/images/urls.py +++ b/openstack_dashboard/dashboards/project/images/urls.py @@ -34,12 +34,12 @@ if settings.ANGULAR_FEATURES['images_panel']: # New angular images urlpatterns = [ url(r'^$', AngularIndexView.as_view(title=title), name='index'), - url(r'', include(image_urls, namespace='images')), - url(r'', include(snapshot_urls, namespace='snapshots')), + url(r'', include((image_urls, 'images'))), + url(r'', include((snapshot_urls, 'snapshots'))), ] else: urlpatterns = [ url(r'^$', views.IndexView.as_view(), name='index'), - url(r'', include(image_urls, namespace='images')), - url(r'', include(snapshot_urls, namespace='snapshots')), + url(r'', include((image_urls, 'images'))), + url(r'', include((snapshot_urls, 'snapshots'))), ] diff --git a/openstack_dashboard/dashboards/project/networks/urls.py b/openstack_dashboard/dashboards/project/networks/urls.py index d307620911..72521d1312 100644 --- a/openstack_dashboard/dashboards/project/networks/urls.py +++ b/openstack_dashboard/dashboards/project/networks/urls.py @@ -48,6 +48,6 @@ urlpatterns = [ subnet_views.UpdateView.as_view(), name='editsubnet'), url(r'^(?P[^/]+)/ports/(?P[^/]+)/update$', port_views.UpdateView.as_view(), name='editport'), - url(r'^subnets/', include(subnet_urls, namespace='subnets')), - url(r'^ports/', include(port_urls, namespace='ports')), + url(r'^subnets/', include((subnet_urls, 'subnets'))), + url(r'^ports/', include((port_urls, 'ports'))), ] diff --git a/openstack_dashboard/test/urls.py b/openstack_dashboard/test/urls.py index cc3a73d15d..2b9024e394 100644 --- a/openstack_dashboard/test/urls.py +++ b/openstack_dashboard/test/urls.py @@ -24,6 +24,8 @@ from django.conf.urls import url from django.contrib.staticfiles.urls import staticfiles_urlpatterns from django.views import defaults +import horizon.base + from openstack_dashboard.api import rest from openstack_dashboard.test.jasmine import jasmine from openstack_dashboard import views @@ -35,7 +37,7 @@ urlpatterns = [ url(r'^auth/', include('openstack_auth.urls')), url(r'^api/', include(rest.urls)), url(r'^jasmine/(.*?)$', jasmine.dispatcher), - url(r'', include(horizon.urls)), + url(r'', horizon.base._wrapped_include(horizon.urls)), ] # Development static app and project media serving using the staticfiles app. diff --git a/openstack_dashboard/urls.py b/openstack_dashboard/urls.py index eba0cc9425..8ddd37ec01 100644 --- a/openstack_dashboard/urls.py +++ b/openstack_dashboard/urls.py @@ -28,6 +28,7 @@ from django.contrib.staticfiles.urls import staticfiles_urlpatterns from django.views import defaults import horizon +import horizon.base from openstack_dashboard.api import rest from openstack_dashboard import views @@ -36,7 +37,7 @@ urlpatterns = [ url(r'^$', views.splash, name='splash'), url(r'^api/', include(rest.urls)), url(r'^header/', views.ExtensibleHeaderView.as_view()), - url(r'', include(horizon.urls)), + url(r'', horizon.base._wrapped_include(horizon.urls)), ] for u in getattr(settings, 'AUTHENTICATION_URLS', ['openstack_auth.urls']):