зеркало из https://github.com/mozilla/FlightDeck.git
* replace filter refactored
* collecting sign in form errors into one error message * parsed error messages may use HTML inside
This commit is contained in:
Родитель
028e722911
Коммит
c5214d1bba
|
@ -7,8 +7,24 @@ register = Library()
|
|||
|
||||
@register.filter
|
||||
def replace(item, value):
|
||||
f, t = value.split(',')
|
||||
return item.replace(f, t)
|
||||
"""Replaces first part of ``value`` with the second one
|
||||
|
||||
:param: value (string) list of 2 items separated by comma
|
||||
:result: (string) ``item`` with the first string replaced by the other
|
||||
"""
|
||||
items = value.split(',')
|
||||
if len(items) != 2:
|
||||
raise TemplateSyntaxError(
|
||||
"Replace filter argument is a comma separated list of 2 items")
|
||||
return item.replace(items[0], items[1])
|
||||
|
||||
|
||||
@register.filter
|
||||
def capitalize(item):
|
||||
"""Return a copy of the string with its first character capitalized and
|
||||
the rest lowercased
|
||||
"""
|
||||
return item.capitalize()
|
||||
|
||||
|
||||
@register.tag
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
{% extends "base.html" %}
|
||||
{% load base_helpers %}
|
||||
{% load safe_csrf %}
|
||||
{# default django template for login page #}
|
||||
|
||||
|
@ -15,11 +16,14 @@
|
|||
|
||||
{% block app_content %}
|
||||
{% if form.errors %}
|
||||
<p class="fd_error" title="Sign in error">
|
||||
{% for sender,subject in form.errors.items %}
|
||||
{% for error in subject %}
|
||||
<p class="fd_error" title="Sign In Error">{{ error|escape }}</p>
|
||||
{{ sender|replace:"username,email address"|capitalize }}:
|
||||
{{ error|escape }}<br/>
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
</p>
|
||||
{% endif %}
|
||||
|
||||
<div class="UI_Login">
|
||||
|
|
|
@ -74,7 +74,7 @@ FlightDeck = Class.refactor(FlightDeck,{
|
|||
parseMessages: function() {
|
||||
['message', 'warning', 'error', 'success', 'info', 'debug'].each(function(t) {
|
||||
$$('.fd_'+t).each(function(el) {
|
||||
this[t].alert(el.get('title') || t, el.get('text'));
|
||||
this[t].alert(el.get('title') || t, el.get('html'));
|
||||
el.destroy();
|
||||
}, this);
|
||||
}, this);
|
||||
|
|
Загрузка…
Ссылка в новой задаче