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
This commit is contained in:
Akihiro Motoki 2018-12-29 05:40:27 +09:00
parent a69ba853a7
commit 28b457bc62
8 changed files with 13 additions and 9 deletions

View File

@ -1,5 +0,0 @@
{% load themes %}
<div class="text-center">
<img class="splash-logo" src={% themable_asset "img/logo-splash.svg" %}>
</div>

View File

@ -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',

View File

@ -0,0 +1,5 @@
{% load themes %}
<div class="text-center">
<img class="splash-logo" src={% themable_asset "img/logo-splash.svg" %}>
</div>

View File

@ -5,7 +5,7 @@
{% for project in projects %}
<li>
<a class="{% if project.enabled and project.id == project_id %} dropdown-selected{% endif %}"
href="{% url 'switch_tenants' project.id %}?next={{ page_url }}"
href="{% url 'switch_tenants' project.id %}{% if page_url %}?next={{ page_url }}{% endif %}"
target="_self">
<span class="fa fa-check dropdown-selected-icon"></span>
<span class="dropdown-title">

View File

@ -4,7 +4,8 @@
<li class="dropdown-header">{% trans "Regions:" %}</li>
{% for region in regions %}
<li>
<a href="{% url 'switch_services_region' region %}?next={{ page_url }}" target="_self">
<a href="{% url 'switch_services_region' region %}{% if page_url %}?next={{ page_url }}{% endif %}"
target="_self">
<span class="region-name dropdown-title">{{ region }}</span>
{% if region == region_name %}
<span class="fa fa-check"></span>

View File

@ -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