From 28b457bc627d76031317c733f42b4701d53a3f85 Mon Sep 17 00:00:00 2001 From: Akihiro Motoki Date: Sat, 29 Dec 2018 05:40:27 +0900 Subject: [PATCH] UT: Detect template rendering errors This commit enables template debug option to detect errors in template rendering in unit tests. Several errors in template rendering are found by enabling the debug option and they are fixed in this commit. Related-Bug: #1809983 Change-Id: I1a2d19f2eae62e16f02d3386abd65527bac4e7a0 --- .../templates/_login_footer.html | 0 .../templates/_login_form_footer.html | 0 horizon/templates/auth/_splash.html | 5 ----- horizon/test/settings.py | 1 + openstack_dashboard/templates/auth/_splash.html | 5 +++++ .../templates/context_selection/_project_list.html | 2 +- .../templates/context_selection/_region_list.html | 3 ++- openstack_dashboard/templatetags/context_selection.py | 6 ++++-- 8 files changed, 13 insertions(+), 9 deletions(-) rename {openstack_dashboard => horizon}/templates/_login_footer.html (100%) rename {openstack_dashboard => horizon}/templates/_login_form_footer.html (100%) create mode 100644 openstack_dashboard/templates/auth/_splash.html diff --git a/openstack_dashboard/templates/_login_footer.html b/horizon/templates/_login_footer.html similarity index 100% rename from openstack_dashboard/templates/_login_footer.html rename to horizon/templates/_login_footer.html diff --git a/openstack_dashboard/templates/_login_form_footer.html b/horizon/templates/_login_form_footer.html similarity index 100% rename from openstack_dashboard/templates/_login_form_footer.html rename to horizon/templates/_login_form_footer.html diff --git a/horizon/templates/auth/_splash.html b/horizon/templates/auth/_splash.html index 8ccdc272cf..e69de29bb2 100644 --- a/horizon/templates/auth/_splash.html +++ b/horizon/templates/auth/_splash.html @@ -1,5 +0,0 @@ -{% load themes %} - -
- -
diff --git a/horizon/test/settings.py b/horizon/test/settings.py index 3945321bb2..5834cdd871 100644 --- a/horizon/test/settings.py +++ b/horizon/test/settings.py @@ -85,6 +85,7 @@ TEMPLATES = [ 'django.contrib.messages.context_processors.messages', 'horizon.context_processors.horizon', ], + 'debug': True, 'loaders': [ 'django.template.loaders.filesystem.Loader', 'django.template.loaders.app_directories.Loader', diff --git a/openstack_dashboard/templates/auth/_splash.html b/openstack_dashboard/templates/auth/_splash.html new file mode 100644 index 0000000000..8ccdc272cf --- /dev/null +++ b/openstack_dashboard/templates/auth/_splash.html @@ -0,0 +1,5 @@ +{% load themes %} + +
+ +
diff --git a/openstack_dashboard/templates/context_selection/_project_list.html b/openstack_dashboard/templates/context_selection/_project_list.html index 6806c30cea..493a86c09e 100644 --- a/openstack_dashboard/templates/context_selection/_project_list.html +++ b/openstack_dashboard/templates/context_selection/_project_list.html @@ -5,7 +5,7 @@ {% for project in projects %}
  • diff --git a/openstack_dashboard/templates/context_selection/_region_list.html b/openstack_dashboard/templates/context_selection/_region_list.html index 16ddedd972..bb1419fcca 100644 --- a/openstack_dashboard/templates/context_selection/_region_list.html +++ b/openstack_dashboard/templates/context_selection/_region_list.html @@ -4,7 +4,8 @@
  • {% for region in regions %}
  • - + {{ region }} {% if region == region_name %} diff --git a/openstack_dashboard/templatetags/context_selection.py b/openstack_dashboard/templatetags/context_selection.py index 8b7718f83f..562791d94a 100644 --- a/openstack_dashboard/templatetags/context_selection.py +++ b/openstack_dashboard/templatetags/context_selection.py @@ -86,9 +86,10 @@ def show_project_list(context): request = context['request'] projects = sorted(context['authorized_tenants'], key=lambda project: project.name.lower()) + panel = request.horizon.get('panel') context = {'projects': projects[:max_proj], 'project_id': request.user.project_id, - 'page_url': request.horizon.get('panel').get_absolute_url()} + 'page_url': panel.get_absolute_url() if panel else None} return context @@ -98,10 +99,11 @@ def show_region_list(context): if 'request' not in context: return {} request = context['request'] + panel = request.horizon.get('panel') context = {'region_name': request.user.services_region, 'regions': sorted(request.user.available_services_regions, key=lambda x: (x or '').lower()), - 'page_url': request.horizon.get('panel').get_absolute_url()} + 'page_url': panel.get_absolute_url() if panel else None} return context