summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimur Sufiev <tsufiev@mirantis.com>2016-08-24 15:46:43 +0300
committerTimur Sufiev <tsufiev@mirantis.com>2016-08-24 16:45:38 +0300
commit9445d15cd133becf0137350ba843526d4548d4d0 (patch)
treecd6c1ac4f0c59571afc9f2be12649ad261e4c56d
parent626f6fc6753a0cdecb99bcfe60d58804b1eafd53 (diff)
downloadhorizon-9445d15cd133becf0137350ba843526d4548d4d0.tar.gz
Fix various issues with compressed angular templates and plugins
First, retrieve current theme only in cases when it already has been provided in the context. That should prevent missing 'THEME' errors when post_compress signal is being processed, for example inside _stylesheets.html which does not provide THEME var into the rendering context. Second, under certain circumstances, offline compression was producing a different hash for compressed angular templates than runtime template renderer was expecting. Make the combined template with all angular templates be a deterministic - convert it from a dictionary to a list of key-value tuples. Various order of dictionary entries in offline and online compress phases seemed to produce 'missing compress hash key' error. Closed-Bug: #1603307 Change-Id: Idb48c3f68da43bba33033a71e6d69bdc112736de
-rw-r--r--horizon/templatetags/angular.py7
-rw-r--r--openstack_dashboard/templates/angular/angular_templates.html4
2 files changed, 7 insertions, 4 deletions
diff --git a/horizon/templatetags/angular.py b/horizon/templatetags/angular.py
index 8f37b565c..b01c8b1ce 100644
--- a/horizon/templatetags/angular.py
+++ b/horizon/templatetags/angular.py
@@ -33,7 +33,6 @@ def update_angular_template_hash(sender, **kwargs):
clients.
"""
context = kwargs['context'] # context the compressor is working with
- theme = context['THEME'] # current theme being compressed
compressed = context['compressed'] # the compressed content
compressed_name = compressed['name'] # name of the compressed content
if compressed_name == 'angular_template_cache_preloads':
@@ -43,6 +42,7 @@ def update_angular_template_hash(sender, **kwargs):
# generate the same key as used in _scripts.html when caching the
# preloads
+ theme = context['THEME'] # current theme being compressed
key = make_template_fragment_key(
"angular",
['template_cache_preloads', theme]
@@ -115,6 +115,9 @@ def angular_templates(context):
# there will simply be no pre-loaded version for this template.
pass
+ templates = [(key, value) for key, value in angular_templates.items()]
+ templates.sort(key=lambda item: item[0])
+
return {
- 'angular_templates': angular_templates
+ 'angular_templates': templates
}
diff --git a/openstack_dashboard/templates/angular/angular_templates.html b/openstack_dashboard/templates/angular/angular_templates.html
index 76575b429..9fe6c2827 100644
--- a/openstack_dashboard/templates/angular/angular_templates.html
+++ b/openstack_dashboard/templates/angular/angular_templates.html
@@ -1,5 +1,5 @@
-{% for static_path, template_html in angular_templates.items %}
+{% for static_path, template_html in angular_templates %}
<script type='text/javascript' id='{{ static_path }}'>
{% include 'angular/angular_templates.js' %}
</script>
-{% endfor %} \ No newline at end of file
+{% endfor %}