diff --git a/horizon/exceptions.py b/horizon/exceptions.py index 069424cca3..c2cf0046ba 100644 --- a/horizon/exceptions.py +++ b/horizon/exceptions.py @@ -31,6 +31,8 @@ from horizon import messages LOG = logging.getLogger(__name__) +SEPERATOR = '\u2026' + class HorizonReporterFilter(SafeExceptionReporterFilter): """Error report filter that's always active, even in DEBUG mode.""" @@ -261,7 +263,7 @@ HANDLE_EXC_METHODS = [ def _append_detail(message, details): - return encoding.force_text(message) + '\u2026' + \ + return encoding.force_text(message) + SEPERATOR + \ encoding.force_text(details) diff --git a/horizon/static/horizon/js/horizon.messages.js b/horizon/static/horizon/js/horizon.messages.js index 444d0ccecb..33cb8f4cad 100644 --- a/horizon/static/horizon/js/horizon.messages.js +++ b/horizon/static/horizon/js/horizon.messages.js @@ -49,6 +49,12 @@ horizon.alert = function (type, message, extra_tags, details) { }; var this_alert = $(template.render(params)).hide().prependTo("#main_content .messages").fadeIn(100); horizon.autoDismissAlert(this_alert); + + // NOTE: messages template engine doesn't support conditional rendering yet + // So it's a temporary work-around to hide details link when details is empty. + if (details === undefined || details === "") { + this_alert.find("#details_link").remove(); + } return this_alert; }; diff --git a/horizon/templates/horizon/client_side/_alert_message.html b/horizon/templates/horizon/client_side/_alert_message.html index 5f008ed5db..cc28637186 100644 --- a/horizon/templates/horizon/client_side/_alert_message.html +++ b/horizon/templates/horizon/client_side/_alert_message.html @@ -15,7 +15,8 @@ [[/safe]] [[^safe]] [[message]] - Details + Details
[[details]]
diff --git a/horizon/templatetags/splitfilter.py b/horizon/templatetags/splitfilter.py index f4055a359f..4d0a76a330 100644 --- a/horizon/templatetags/splitfilter.py +++ b/horizon/templatetags/splitfilter.py @@ -12,9 +12,11 @@ from django import template +from horizon import exceptions + register = template.Library() @register.filter(name='split_message') def split_message(value): - return value.split('\u2026') + return value.split(exceptions.SEPERATOR) diff --git a/horizon/test/unit/test_exceptions.py b/horizon/test/unit/test_exceptions.py index 286abd78a2..1725512866 100644 --- a/horizon/test/unit/test_exceptions.py +++ b/horizon/test/unit/test_exceptions.py @@ -26,7 +26,8 @@ class HandleTests(test.TestCase): # 'Because the container is not empty, it can not be deleted.' expected = ['error', force_text(translated_unicode + - '\u2026' + translated_unicode), ''] + exceptions.SEPERATOR + + translated_unicode), ''] req = self.request req.META['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest' @@ -80,7 +81,7 @@ class HandleTests(test.TestCase): message = u"Couldn't make the thing" exc_msg = u"Exception string" details = "custom detail message" - expected = ['error', message + '\u2026' + details, ''] + expected = ['error', message + exceptions.SEPERATOR + details, ''] req = self.request req.META['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest'