summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2016-09-27 11:20:35 +0000
committerGerrit Code Review <review@openstack.org>2016-09-27 11:20:35 +0000
commitc2eaffeb2a879a226980ec32124821019c63623d (patch)
treef40a817f380da80d52ef027f8d8e381f90e58f15
parent8b417374f7572a32714252e07d95bacc1c232c07 (diff)
parentd27528e8315559c4bae809f21d741906142586dc (diff)
Merge "Fix compatibility issues with Django 1.10" into stable/newton
-rw-r--r--horizon/base.py9
-rw-r--r--horizon/templatetags/breadcrumb_nav.py6
-rw-r--r--horizon/test/settings.py38
-rw-r--r--openstack_dashboard/dashboards/admin/hypervisors/views.py3
-rw-r--r--openstack_dashboard/dashboards/admin/networks/ports/views.py3
-rw-r--r--openstack_dashboard/dashboards/identity/projects/tests.py15
-rw-r--r--openstack_dashboard/dashboards/project/containers/tests.py14
-rw-r--r--openstack_dashboard/dashboards/project/loadbalancers/views.py3
-rw-r--r--openstack_dashboard/dashboards/project/networks/ports/views.py3
-rw-r--r--openstack_dashboard/dashboards/project/networks/subnets/views.py3
-rw-r--r--openstack_dashboard/dashboards/project/routers/tests.py15
-rw-r--r--openstack_dashboard/dashboards/project/stacks/tests.py72
-rw-r--r--openstack_dashboard/dashboards/project/volumes/volumes/tests.py2
-rw-r--r--openstack_dashboard/local/local_settings.py.example1
-rw-r--r--openstack_dashboard/settings.py57
-rw-r--r--openstack_dashboard/test/settings.py13
-rw-r--r--openstack_dashboard/test/tests/error_pages.py9
-rw-r--r--releasenotes/notes/bp-dj110-438f26c21f283c46.yaml10
18 files changed, 170 insertions, 106 deletions
diff --git a/horizon/base.py b/horizon/base.py
index 4b57e9b..ab4f5e1 100644
--- a/horizon/base.py
+++ b/horizon/base.py
@@ -26,6 +26,7 @@ import inspect
26import logging 26import logging
27import os 27import os
28 28
29import django
29from django.conf import settings 30from django.conf import settings
30from django.conf.urls import include 31from django.conf.urls import include
31from django.conf.urls import url 32from django.conf.urls import url
@@ -54,7 +55,13 @@ LOG = logging.getLogger(__name__)
54def _decorate_urlconf(urlpatterns, decorator, *args, **kwargs): 55def _decorate_urlconf(urlpatterns, decorator, *args, **kwargs):
55 for pattern in urlpatterns: 56 for pattern in urlpatterns:
56 if getattr(pattern, 'callback', None): 57 if getattr(pattern, 'callback', None):
57 pattern._callback = decorator(pattern.callback, *args, **kwargs) 58 decorated = decorator(pattern.callback, *args, **kwargs)
59 if django.VERSION >= (1, 10):
60 pattern.callback = decorated
61 else:
62 # prior to 1.10 callback was a property and we had
63 # to modify the private attribute behind the property
64 pattern._callback = decorated
58 if getattr(pattern, 'url_patterns', []): 65 if getattr(pattern, 'url_patterns', []):
59 _decorate_urlconf(pattern.url_patterns, decorator, *args, **kwargs) 66 _decorate_urlconf(pattern.url_patterns, decorator, *args, **kwargs)
60 67
diff --git a/horizon/templatetags/breadcrumb_nav.py b/horizon/templatetags/breadcrumb_nav.py
index f2cacb3..ef05723 100644
--- a/horizon/templatetags/breadcrumb_nav.py
+++ b/horizon/templatetags/breadcrumb_nav.py
@@ -48,13 +48,13 @@ def breadcrumb_nav(context):
48 custom_breadcrumb = context.get('custom_breadcrumb') 48 custom_breadcrumb = context.get('custom_breadcrumb')
49 49
50 # Build list of tuples (name, optional url) 50 # Build list of tuples (name, optional url)
51 breadcrumb.append((dashboard.name,)) 51 breadcrumb.append((dashboard.name, None))
52 if panel_group: 52 if panel_group:
53 breadcrumb.append((panel_group.name,)) 53 breadcrumb.append((panel_group.name, None))
54 if panel: 54 if panel:
55 breadcrumb.append((panel.name, panel.get_absolute_url())) 55 breadcrumb.append((panel.name, panel.get_absolute_url()))
56 if custom_breadcrumb: 56 if custom_breadcrumb:
57 breadcrumb.extend(custom_breadcrumb) 57 breadcrumb.extend(custom_breadcrumb)
58 breadcrumb.append((context.get('page_title'),)) 58 breadcrumb.append((context.get('page_title'), None))
59 59
60 return {'breadcrumb': breadcrumb} 60 return {'breadcrumb': breadcrumb}
diff --git a/horizon/test/settings.py b/horizon/test/settings.py
index d275bc9..e261343 100644
--- a/horizon/test/settings.py
+++ b/horizon/test/settings.py
@@ -31,7 +31,6 @@ ROOT_PATH = os.path.dirname(os.path.abspath(__file__))
31STATIC_ROOT = os.path.abspath(os.path.join(ROOT_PATH, '..', 'static')) 31STATIC_ROOT = os.path.abspath(os.path.join(ROOT_PATH, '..', 'static'))
32 32
33DEBUG = False 33DEBUG = False
34TEMPLATE_DEBUG = DEBUG
35TESTSERVER = 'http://testserver' 34TESTSERVER = 'http://testserver'
36 35
37SECRET_KEY = 'elj1IWiLoWHgcyYxFVLj7cM5rGOOxWl0' 36SECRET_KEY = 'elj1IWiLoWHgcyYxFVLj7cM5rGOOxWl0'
@@ -73,20 +72,28 @@ MIDDLEWARE_CLASSES = (
73 'django.middleware.clickjacking.XFrameOptionsMiddleware', 72 'django.middleware.clickjacking.XFrameOptionsMiddleware',
74) 73)
75 74
76TEMPLATE_CONTEXT_PROCESSORS = ( 75TEMPLATES = [
77 'django.core.context_processors.debug', 76 {
78 'django.core.context_processors.i18n', 77 'BACKEND': 'django.template.backends.django.DjangoTemplates',
79 'django.core.context_processors.request', 78 'DIRS': [os.path.join(ROOT_PATH, 'tests', 'templates')],
80 'django.core.context_processors.media', 79 'OPTIONS': {
81 'django.core.context_processors.static', 80 'context_processors': [
82 'django.contrib.messages.context_processors.messages', 81 'django.template.context_processors.debug',
83 'horizon.context_processors.horizon') 82 'django.template.context_processors.i18n',
84 83 'django.template.context_processors.request',
85TEMPLATE_LOADERS = ( 84 'django.template.context_processors.media',
86 'django.template.loaders.filesystem.Loader', 85 'django.template.context_processors.static',
87 'django.template.loaders.app_directories.Loader', 86 'django.contrib.messages.context_processors.messages',
88 'horizon.loaders.TemplateLoader' 87 'horizon.context_processors.horizon',
89) 88 ],
89 'loaders': [
90 'django.template.loaders.filesystem.Loader',
91 'django.template.loaders.app_directories.Loader',
92 'horizon.loaders.TemplateLoader'
93 ],
94 },
95 },
96]
90 97
91STATIC_URL = '/static/' 98STATIC_URL = '/static/'
92WEBROOT = '/' 99WEBROOT = '/'
@@ -94,7 +101,6 @@ WEBROOT = '/'
94MESSAGE_STORAGE = 'django.contrib.messages.storage.cookie.CookieStorage' 101MESSAGE_STORAGE = 'django.contrib.messages.storage.cookie.CookieStorage'
95 102
96ROOT_URLCONF = 'horizon.test.urls' 103ROOT_URLCONF = 'horizon.test.urls'
97TEMPLATE_DIRS = (os.path.join(ROOT_PATH, 'tests', 'templates'),)
98SITE_ID = 1 104SITE_ID = 1
99SITE_BRANDING = 'Horizon' 105SITE_BRANDING = 'Horizon'
100 106
diff --git a/openstack_dashboard/dashboards/admin/hypervisors/views.py b/openstack_dashboard/dashboards/admin/hypervisors/views.py
index 55c210c..5e770f6 100644
--- a/openstack_dashboard/dashboards/admin/hypervisors/views.py
+++ b/openstack_dashboard/dashboards/admin/hypervisors/views.py
@@ -67,7 +67,6 @@ class AdminDetailView(tables.DataTableView):
67 def get_context_data(self, **kwargs): 67 def get_context_data(self, **kwargs):
68 context = super(AdminDetailView, self).get_context_data(**kwargs) 68 context = super(AdminDetailView, self).get_context_data(**kwargs)
69 hypervisor_name = self.kwargs['hypervisor'].split('_', 1)[1] 69 hypervisor_name = self.kwargs['hypervisor'].split('_', 1)[1]
70 breadcrumb = [ 70 breadcrumb = [(hypervisor_name, None)]
71 (hypervisor_name,), ]
72 context['custom_breadcrumb'] = breadcrumb 71 context['custom_breadcrumb'] = breadcrumb
73 return context 72 return context
diff --git a/openstack_dashboard/dashboards/admin/networks/ports/views.py b/openstack_dashboard/dashboards/admin/networks/ports/views.py
index 30b3aae..a19e048 100644
--- a/openstack_dashboard/dashboards/admin/networks/ports/views.py
+++ b/openstack_dashboard/dashboards/admin/networks/ports/views.py
@@ -87,7 +87,8 @@ class DetailView(project_views.DetailView):
87 breadcrumb = [ 87 breadcrumb = [
88 (_("Networks"), self.get_redirect_url()), 88 (_("Networks"), self.get_redirect_url()),
89 ((port.network_name or port.network_id), port.network_url), 89 ((port.network_name or port.network_id), port.network_url),
90 (_("Ports"),), ] 90 (_("Ports"), None)
91 ]
91 context["custom_breadcrumb"] = breadcrumb 92 context["custom_breadcrumb"] = breadcrumb
92 context["url"] = \ 93 context["url"] = \
93 reverse('horizon:admin:networks:ports_tab', args=[port.network_id]) 94 reverse('horizon:admin:networks:ports_tab', args=[port.network_id])
diff --git a/openstack_dashboard/dashboards/identity/projects/tests.py b/openstack_dashboard/dashboards/identity/projects/tests.py
index 9176d59..9e4e08f 100644
--- a/openstack_dashboard/dashboards/identity/projects/tests.py
+++ b/openstack_dashboard/dashboards/identity/projects/tests.py
@@ -17,6 +17,7 @@ import logging
17import os 17import os
18import unittest 18import unittest
19 19
20import django
20from django.core.urlresolvers import reverse 21from django.core.urlresolvers import reverse
21from django import http 22from django import http
22from django.test.utils import override_settings 23from django.test.utils import override_settings
@@ -288,11 +289,15 @@ class CreateProjectWorkflowTests(test.BaseAdminViewTests):
288 res = self.client.get(reverse('horizon:identity:projects:create')) 289 res = self.client.get(reverse('horizon:identity:projects:create'))
289 290
290 self.assertTemplateUsed(res, views.WorkflowView.template_name) 291 self.assertTemplateUsed(res, views.WorkflowView.template_name)
291 self.assertContains(res, ''' 292 if django.VERSION >= (1, 10):
292 <input class="form-control" 293 pattern = ('<input class="form-control" '
293 id="id_subnet" min="-1" 294 'id="id_subnet" min="-1" '
294 name="subnet" type="number" value="10" /> 295 'name="subnet" type="number" value="10" required/>')
295 ''', html=True) 296 else:
297 pattern = ('<input class="form-control" '
298 'id="id_subnet" min="-1" '
299 'name="subnet" type="number" value="10"/>')
300 self.assertContains(res, pattern, html=True)
296 301
297 workflow = res.context['workflow'] 302 workflow = res.context['workflow']
298 self.assertEqual(res.context['workflow'].name, 303 self.assertEqual(res.context['workflow'].name,
diff --git a/openstack_dashboard/dashboards/project/containers/tests.py b/openstack_dashboard/dashboards/project/containers/tests.py
index 8114bef..1fd6729 100644
--- a/openstack_dashboard/dashboards/project/containers/tests.py
+++ b/openstack_dashboard/dashboards/project/containers/tests.py
@@ -20,6 +20,7 @@ import copy
20import email.header 20import email.header
21import tempfile 21import tempfile
22 22
23import django
23from django.core.files.uploadedfile import InMemoryUploadedFile # noqa 24from django.core.files.uploadedfile import InMemoryUploadedFile # noqa
24from django.core.urlresolvers import reverse 25from django.core.urlresolvers import reverse
25from django import http 26from django import http
@@ -436,9 +437,16 @@ class SwiftTests(test.TestCase):
436 args=[container.name, obj.name]) 437 args=[container.name, obj.name])
437 res = self.client.get(copy_url) 438 res = self.client.get(copy_url)
438 # The copy's name must appear in initial data 439 # The copy's name must appear in initial data
439 pattern = ('<input id="id_new_object_name" value="%s" ' 440 if django.VERSION >= (1, 10):
440 'name="new_object_name" type="text" ' 441 pattern = ('<input id="id_new_object_name" value="%s" '
441 'class="form-control" maxlength="255" />' % copy_name) 442 'name="new_object_name" type="text" '
443 'class="form-control" '
444 'maxlength="255" required/>' % copy_name)
445 else:
446 pattern = ('<input id="id_new_object_name" value="%s" '
447 'name="new_object_name" type="text" '
448 'class="form-control" '
449 'maxlength="255"/>' % copy_name)
442 self.assertContains(res, pattern, html=True) 450 self.assertContains(res, pattern, html=True)
443 451
444 def test_get_copy_name(self): 452 def test_get_copy_name(self):
diff --git a/openstack_dashboard/dashboards/project/loadbalancers/views.py b/openstack_dashboard/dashboards/project/loadbalancers/views.py
index 30e552a..192b309 100644
--- a/openstack_dashboard/dashboards/project/loadbalancers/views.py
+++ b/openstack_dashboard/dashboards/project/loadbalancers/views.py
@@ -139,7 +139,8 @@ class VipDetailsView(tabs.TabView):
139 (vip_nav, 139 (vip_nav,
140 reverse('horizon:project:loadbalancers:vipdetails', 140 reverse('horizon:project:loadbalancers:vipdetails',
141 args=(vip.id,))), 141 args=(vip.id,))),
142 (_("VIP"),), ] 142 (_("VIP"), None)
143 ]
143 context["custom_breadcrumb"] = breadcrumb 144 context["custom_breadcrumb"] = breadcrumb
144 return context 145 return context
145 146
diff --git a/openstack_dashboard/dashboards/project/networks/ports/views.py b/openstack_dashboard/dashboards/project/networks/ports/views.py
index 0888877..3d42de1 100644
--- a/openstack_dashboard/dashboards/project/networks/ports/views.py
+++ b/openstack_dashboard/dashboards/project/networks/ports/views.py
@@ -90,7 +90,8 @@ class DetailView(tabs.TabbedTableView):
90 # TODO(robcresswell) Add URL for "Ports" crumb after bug/1416838 90 # TODO(robcresswell) Add URL for "Ports" crumb after bug/1416838
91 breadcrumb = [ 91 breadcrumb = [
92 ((port.network_name or port.network_id), port.network_url), 92 ((port.network_name or port.network_id), port.network_url),
93 (_("Ports"),), ] 93 (_("Ports"), None)
94 ]
94 context["custom_breadcrumb"] = breadcrumb 95 context["custom_breadcrumb"] = breadcrumb
95 context["port"] = port 96 context["port"] = port
96 context["url"] = self.get_redirect_url() 97 context["url"] = self.get_redirect_url()
diff --git a/openstack_dashboard/dashboards/project/networks/subnets/views.py b/openstack_dashboard/dashboards/project/networks/subnets/views.py
index eceda8a..d1dff4d 100644
--- a/openstack_dashboard/dashboards/project/networks/subnets/views.py
+++ b/openstack_dashboard/dashboards/project/networks/subnets/views.py
@@ -154,7 +154,8 @@ class DetailView(tabs.TabView):
154 # TODO(robcresswell) Add URL for "Subnets" crumb after bug/1416838 154 # TODO(robcresswell) Add URL for "Subnets" crumb after bug/1416838
155 breadcrumb = [ 155 breadcrumb = [
156 (network_nav, subnet.network_url), 156 (network_nav, subnet.network_url),
157 (_("Subnets"),), ] 157 (_("Subnets"), None)
158 ]
158 context["custom_breadcrumb"] = breadcrumb 159 context["custom_breadcrumb"] = breadcrumb
159 context["subnet"] = subnet 160 context["subnet"] = subnet
160 context["url"] = \ 161 context["url"] = \
diff --git a/openstack_dashboard/dashboards/project/routers/tests.py b/openstack_dashboard/dashboards/project/routers/tests.py
index 3602203..5a25b52 100644
--- a/openstack_dashboard/dashboards/project/routers/tests.py
+++ b/openstack_dashboard/dashboards/project/routers/tests.py
@@ -13,6 +13,7 @@
13# under the License. 13# under the License.
14import copy 14import copy
15 15
16import django
16from django.core.urlresolvers import reverse 17from django.core.urlresolvers import reverse
17from django import http 18from django import http
18 19
@@ -441,11 +442,15 @@ class RouterActionTests(RouterMixin, test.TestCase):
441 442
442 self.assertTemplateUsed(res, 'project/routers/update.html') 443 self.assertTemplateUsed(res, 'project/routers/update.html')
443 self.assertContains(res, 'Router Type') 444 self.assertContains(res, 'Router Type')
444 self.assertContains( 445 if django.VERSION >= (1, 10):
445 res, 446 pattern = ('<input class="form-control" id="id_mode" name="mode" '
446 '<input class="form-control" id="id_mode" name="mode" ' 447 'readonly="readonly" type="text" value="distributed" '
447 'readonly="readonly" type="text" value="distributed" />', 448 'required/>')
448 html=True) 449 else:
450 pattern = ('<input class="form-control" id="id_mode" name="mode" '
451 'readonly="readonly" type="text" '
452 'value="distributed" />')
453 self.assertContains(res, pattern, html=True)
449 self.assertNotContains(res, 'centralized') 454 self.assertNotContains(res, 'centralized')
450 455
451 @test.create_stubs({api.neutron: ('router_get', 456 @test.create_stubs({api.neutron: ('router_get',
diff --git a/openstack_dashboard/dashboards/project/stacks/tests.py b/openstack_dashboard/dashboards/project/stacks/tests.py
index 4ecfc39..f1bbb06 100644
--- a/openstack_dashboard/dashboards/project/stacks/tests.py
+++ b/openstack_dashboard/dashboards/project/stacks/tests.py
@@ -13,6 +13,7 @@
13import json 13import json
14import re 14import re
15 15
16import django
16from django.conf import settings 17from django.conf import settings
17from django.core import exceptions 18from django.core import exceptions
18from django.core.urlresolvers import reverse 19from django.core.urlresolvers import reverse
@@ -394,16 +395,25 @@ class StackTests(test.TestCase):
394 self.assertTemplateUsed(res, 'project/stacks/create.html') 395 self.assertTemplateUsed(res, 'project/stacks/create.html')
395 396
396 # ensure the fields were rendered correctly 397 # ensure the fields were rendered correctly
397 self.assertContains(res, 398 if django.VERSION >= (1, 10):
398 '<input class="form-control" ' 399 pattern = ('<input class="form-control" '
399 'id="id___param_public_string" ' 400 'id="id___param_public_string" '
400 'name="__param_public_string" ' 401 'name="__param_public_string" type="text" required/>')
401 'type="text" />', html=True) 402 secret = ('<input class="form-control" '
402 self.assertContains(res, 403 'id="id___param_secret_string" '
403 '<input class="form-control" ' 404 'name="__param_secret_string" '
404 'id="id___param_secret_string" ' 405 'type="password" required>')
405 'name="__param_secret_string" ' 406 else:
406 'type="password" />', html=True) 407 pattern = ('<input class="form-control" '
408 'id="id___param_public_string" '
409 'name="__param_public_string" type="text" />')
410 secret = ('<input class="form-control" '
411 'id="id___param_secret_string" '
412 'name="__param_secret_string" '
413 'type="password" />')
414
415 self.assertContains(res, pattern, html=True)
416 self.assertContains(res, secret, html=True)
407 417
408 @test.create_stubs({api.heat: ('template_validate',)}) 418 @test.create_stubs({api.heat: ('template_validate',)})
409 def test_launch_stack_with_parameter_group(self): 419 def test_launch_stack_with_parameter_group(self):
@@ -560,30 +570,24 @@ class StackTests(test.TestCase):
560 self.assertTemplateUsed(res, 'project/stacks/create.html') 570 self.assertTemplateUsed(res, 'project/stacks/create.html')
561 571
562 # ensure the fields were rendered correctly 572 # ensure the fields were rendered correctly
563 self.assertContains(res, 573 if django.VERSION >= (1, 10):
564 '<input class="form-control" ' 574 input_str = ('<input class="form-control" '
565 'id="id___param_param1" ' 575 'id="id___param_param{0}" '
566 'name="__param_param1" ' 576 'name="__param_param{0}" type="{1}" required/>')
567 'type="text" />', html=True) 577 else:
568 self.assertContains(res, 578 input_str = ('<input class="form-control" '
569 '<input class="form-control" ' 579 'id="id___param_param{0}" '
570 'id="id___param_param2" ' 580 'name="__param_param{0}" type="{1}"/>')
571 'name="__param_param2" ' 581
572 'type="number" />', html=True) 582 self.assertContains(res, input_str.format(1, 'text'), html=True)
573 self.assertContains(res, 583 self.assertContains(res, input_str.format(2, 'number'), html=True)
574 '<input class="form-control" ' 584 self.assertContains(res, input_str.format(3, 'text'), html=True)
575 'id="id___param_param3" ' 585 self.assertContains(res, input_str.format(4, 'text'), html=True)
576 'name="__param_param3" ' 586 self.assertContains(
577 'type="text" />', html=True) 587 res,
578 self.assertContains(res, 588 '<input id="id___param_param5" name="__param_param5" '
579 '<input class="form-control" ' 589 'type="checkbox">',
580 'id="id___param_param4" ' 590 html=True)
581 'name="__param_param4" '
582 'type="text" />', html=True)
583 self.assertContains(res,
584 '<input id="id___param_param5" '
585 'name="__param_param5" '
586 'type="checkbox" />', html=True)
587 591
588 # post some sample data and make sure it validates 592 # post some sample data and make sure it validates
589 url = reverse('horizon:project:stacks:launch') 593 url = reverse('horizon:project:stacks:launch')
diff --git a/openstack_dashboard/dashboards/project/volumes/volumes/tests.py b/openstack_dashboard/dashboards/project/volumes/volumes/tests.py
index 41b2ac0..3138c17 100644
--- a/openstack_dashboard/dashboards/project/volumes/volumes/tests.py
+++ b/openstack_dashboard/dashboards/project/volumes/volumes/tests.py
@@ -1093,7 +1093,7 @@ class VolumeViewTests(test.ResetImageAPIVersionMixin, test.TestCase):
1093 def _get_volume_row_action_from_ajax(self, res, action_name, row_id): 1093 def _get_volume_row_action_from_ajax(self, res, action_name, row_id):
1094 def _matches_row_id(context_row): 1094 def _matches_row_id(context_row):
1095 return (len(context_row.dicts) > 1 and 1095 return (len(context_row.dicts) > 1 and
1096 isinstance(context_row.dicts[1], dict) and 1096 hasattr(context_row.dicts[1], 'get') and
1097 context_row.dicts[1].get('row_id', None) == row_id) 1097 context_row.dicts[1].get('row_id', None) == row_id)
1098 1098
1099 matching = list(moves.filter(lambda r: _matches_row_id(r), 1099 matching = list(moves.filter(lambda r: _matches_row_id(r),
diff --git a/openstack_dashboard/local/local_settings.py.example b/openstack_dashboard/local/local_settings.py.example
index 8044ddb..07607ce 100644
--- a/openstack_dashboard/local/local_settings.py.example
+++ b/openstack_dashboard/local/local_settings.py.example
@@ -10,7 +10,6 @@ from openstack_dashboard import exceptions
10from openstack_dashboard.settings import HORIZON_CONFIG 10from openstack_dashboard.settings import HORIZON_CONFIG
11 11
12DEBUG = True 12DEBUG = True
13TEMPLATE_DEBUG = DEBUG
14 13
15 14
16# WEBROOT is the location relative to Webserver root 15# WEBROOT is the location relative to Webserver root
diff --git a/openstack_dashboard/settings.py b/openstack_dashboard/settings.py
index 419b280..e772626 100644
--- a/openstack_dashboard/settings.py
+++ b/openstack_dashboard/settings.py
@@ -42,7 +42,6 @@ if ROOT_PATH not in sys.path:
42 sys.path.append(ROOT_PATH) 42 sys.path.append(ROOT_PATH)
43 43
44DEBUG = False 44DEBUG = False
45TEMPLATE_DEBUG = DEBUG
46 45
47SITE_BRANDING = 'OpenStack Dashboard' 46SITE_BRANDING = 'OpenStack Dashboard'
48 47
@@ -115,29 +114,35 @@ MIDDLEWARE_CLASSES = (
115 'django.middleware.clickjacking.XFrameOptionsMiddleware', 114 'django.middleware.clickjacking.XFrameOptionsMiddleware',
116) 115)
117 116
118TEMPLATE_CONTEXT_PROCESSORS = ( 117CACHED_TEMPLATE_LOADERS = [
119 'django.core.context_processors.debug',
120 'django.core.context_processors.i18n',
121 'django.core.context_processors.request',
122 'django.core.context_processors.media',
123 'django.core.context_processors.static',
124 'django.contrib.messages.context_processors.messages',
125 'horizon.context_processors.horizon',
126 'openstack_dashboard.context_processors.openstack',
127)
128
129TEMPLATE_LOADERS = ('horizon.themes.ThemeTemplateLoader',)
130
131CACHED_TEMPLATE_LOADERS = (
132 'django.template.loaders.filesystem.Loader', 118 'django.template.loaders.filesystem.Loader',
133 'django.template.loaders.app_directories.Loader', 119 'django.template.loaders.app_directories.Loader',
134 'horizon.loaders.TemplateLoader',) 120 'horizon.loaders.TemplateLoader'
121]
135 122
136ADD_TEMPLATE_LOADERS = [] 123ADD_TEMPLATE_LOADERS = []
137 124
138TEMPLATE_DIRS = ( 125TEMPLATES = [
139 os.path.join(ROOT_PATH, 'templates'), 126 {
140) 127 'BACKEND': 'django.template.backends.django.DjangoTemplates',
128 'DIRS': [os.path.join(ROOT_PATH, 'templates')],
129 'OPTIONS': {
130 'context_processors': [
131 'django.template.context_processors.debug',
132 'django.template.context_processors.i18n',
133 'django.template.context_processors.request',
134 'django.template.context_processors.media',
135 'django.template.context_processors.static',
136 'django.contrib.messages.context_processors.messages',
137 'horizon.context_processors.horizon',
138 'openstack_dashboard.context_processors.openstack',
139 ],
140 'loaders': [
141 'horizon.themes.ThemeTemplateLoader'
142 ],
143 },
144 },
145]
141 146
142STATICFILES_FINDERS = ( 147STATICFILES_FINDERS = (
143 'django.contrib.staticfiles.finders.FileSystemFinder', 148 'django.contrib.staticfiles.finders.FileSystemFinder',
@@ -309,13 +314,19 @@ try:
309except ImportError: 314except ImportError:
310 logging.warning("No local_settings file found.") 315 logging.warning("No local_settings file found.")
311 316
317# configure template debugging
318TEMPLATES[0]['OPTIONS']['debug'] = DEBUG
319
312# Template loaders 320# Template loaders
313if DEBUG: 321if DEBUG:
314 TEMPLATE_LOADERS += CACHED_TEMPLATE_LOADERS + tuple(ADD_TEMPLATE_LOADERS) 322 TEMPLATES[0]['OPTIONS']['loaders'].extend(
323 CACHED_TEMPLATE_LOADERS + ADD_TEMPLATE_LOADERS
324 )
315else: 325else:
316 TEMPLATE_LOADERS += ( 326 TEMPLATES[0]['OPTIONS']['loaders'].extend(
317 ('django.template.loaders.cached.Loader', CACHED_TEMPLATE_LOADERS), 327 [('django.template.loaders.cached.Loader', CACHED_TEMPLATE_LOADERS)] +
318 ) + tuple(ADD_TEMPLATE_LOADERS) 328 ADD_TEMPLATE_LOADERS
329 )
319 330
320NG_TEMPLATE_CACHE_AGE = NG_TEMPLATE_CACHE_AGE if not DEBUG else 0 331NG_TEMPLATE_CACHE_AGE = NG_TEMPLATE_CACHE_AGE if not DEBUG else 0
321 332
diff --git a/openstack_dashboard/test/settings.py b/openstack_dashboard/test/settings.py
index 2622781..4a84322 100644
--- a/openstack_dashboard/test/settings.py
+++ b/openstack_dashboard/test/settings.py
@@ -36,8 +36,13 @@ WEBROOT = '/'
36SECRET_KEY = secret_key.generate_or_read_from_file( 36SECRET_KEY = secret_key.generate_or_read_from_file(
37 os.path.join(TEST_DIR, '.secret_key_store')) 37 os.path.join(TEST_DIR, '.secret_key_store'))
38ROOT_URLCONF = 'openstack_dashboard.test.urls' 38ROOT_URLCONF = 'openstack_dashboard.test.urls'
39TEMPLATE_DIRS = ( 39
40 os.path.join(TEST_DIR, 'templates'), 40TEMPLATES[0]['DIRS'] = [
41 os.path.join(TEST_DIR, 'templates')
42]
43
44TEMPLATES[0]['OPTIONS']['context_processors'].append(
45 'openstack_dashboard.context_processors.openstack'
41) 46)
42 47
43CUSTOM_THEME_PATH = 'themes/default' 48CUSTOM_THEME_PATH = 'themes/default'
@@ -58,10 +63,6 @@ AVAILABLE_THEMES = [
58# Theme Static Directory 63# Theme Static Directory
59THEME_COLLECTION_DIR = 'themes' 64THEME_COLLECTION_DIR = 'themes'
60 65
61TEMPLATE_CONTEXT_PROCESSORS += (
62 'openstack_dashboard.context_processors.openstack',
63)
64
65COMPRESS_OFFLINE = False 66COMPRESS_OFFLINE = False
66 67
67INSTALLED_APPS = ( 68INSTALLED_APPS = (
diff --git a/openstack_dashboard/test/tests/error_pages.py b/openstack_dashboard/test/tests/error_pages.py
index 8e2204e..3b55c1c 100644
--- a/openstack_dashboard/test/tests/error_pages.py
+++ b/openstack_dashboard/test/tests/error_pages.py
@@ -25,7 +25,12 @@ class ErrorPageTests(test.TestCase):
25 urls = 'openstack_dashboard.test.error_pages_urls' 25 urls = 'openstack_dashboard.test.error_pages_urls'
26 26
27 def test_500_error(self): 27 def test_500_error(self):
28 TEMPLATE_DIRS = (path.join(settings.ROOT_PATH, 'templates'),) 28 with self.settings(
29 with self.settings(TEMPLATE_DIRS=TEMPLATE_DIRS): 29 TEMPLATES=[{
30 'DIRS': [path.join(settings.ROOT_PATH, 'templates')],
31 'BACKEND': ('django.template.backends.django.'
32 'DjangoTemplates')
33 }],
34 ROOT_URLCONF=self.urls):
30 response = self.client.get('/500/') 35 response = self.client.get('/500/')
31 self.assertIn(b'Server error', response.content) 36 self.assertIn(b'Server error', response.content)
diff --git a/releasenotes/notes/bp-dj110-438f26c21f283c46.yaml b/releasenotes/notes/bp-dj110-438f26c21f283c46.yaml
new file mode 100644
index 0000000..8ca244a
--- /dev/null
+++ b/releasenotes/notes/bp-dj110-438f26c21f283c46.yaml
@@ -0,0 +1,10 @@
1---
2upgrade:
3 - The ``TEMPLATE_*`` settings have been replaced with a ``TEMPLATE`` dict.
4 This will likely cause issues when porting settings to this version of
5 Horizon. The TEMPLATE_DEBUG setting has been removed and is tied to
6 the DEBUG setting now. A detailed explanation of this dict can be found at
7 https://docs.djangoproject.com/en/1.10/ref/settings/#templates
8 - The ``is_authenticated()`` and ``is_anonymous()`` functions in Django
9 OpenStack Auth's ``User`` class are properties when running under Django
10 1.10, and no longer take a margin parameter.