Projet

Général

Profil

0001-fix_user_model-delay-formatting-of-username-field-s-.patch

Benjamin Dauvergne, 01 mai 2015 14:26

Télécharger (1,61 ko)

Voir les différences:

Subject: [PATCH] fix_user_model: delay formatting of username field's
 help_text until rendering by ancapsulating operator % with allow_lazy (fixes
 #7123)

 src/authentic2/fix_user_model.py | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
src/authentic2/fix_user_model.py
1 1
import re
2 2

  
3 3
from django.utils.translation import ugettext_lazy as _
4
from django.utils.functional import allow_lazy
4 5
from django.core.validators import MaxLengthValidator, RegexValidator
5 6

  
7
# Allow delaying formatting
8
uinterpolate= allow_lazy(lambda self, arg: self % arg, unicode)
9

  
6 10
#from django.db.models.signals import class_prepared
7 11
#def longer_username_signal(sender, *args, **kwargs):
8 12
#    if (sender.__name__ == "User" and
......
31 35
        return
32 36

  
33 37
    field.max_length = MAX_USERNAME_LENGTH
34
    field.help_text = _("Required, %s characters or fewer. Only letters, "
38
    field.help_text = uinterpolate(_("Required, %s characters or fewer. Only letters, "
35 39
                        "numbers, and @, ., +, -, or _ "
36
                        "characters." % MAX_USERNAME_LENGTH)
40
                        "characters."), 255)
37 41
    if app_settings.A2_USERNAME_HELP_TEXT:
38 42
        field.help_text = app_settings.A2_USERNAME_HELP_TEXT
39 43
    field.label = _('username')
40
-