Merge "Refactor error messages."
This commit is contained in:
commit
d9bf46371e
@ -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)
|
||||
|
||||
|
||||
|
@ -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;
|
||||
};
|
||||
|
||||
|
@ -15,7 +15,8 @@
|
||||
[[/safe]]
|
||||
[[^safe]]
|
||||
[[message]]
|
||||
<a href="#message_details" data-toggle="collapse" data-target="#message_details">Details</a>
|
||||
<a id="details_link" href="#message_details" data-toggle="collapse"
|
||||
data-target="#message_details">Details</a>
|
||||
<div id="message_details" class="collapse">
|
||||
[[details]]
|
||||
</div>
|
||||
|
@ -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)
|
||||
|
@ -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'
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user