From 9445d15cd133becf0137350ba843526d4548d4d0 Mon Sep 17 00:00:00 2001 From: Timur Sufiev Date: Wed, 24 Aug 2016 15:46:43 +0300 Subject: 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 --- horizon/templatetags/angular.py | 7 +++++-- openstack_dashboard/templates/angular/angular_templates.html | 4 ++-- 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 %} -{% endfor %} \ No newline at end of file +{% endfor %} -- cgit v1.2.1