Projet

Général

Profil

0001-attribute_kinds-add-person-title.patch

Benjamin Dauvergne, 08 mai 2015 16:09

Télécharger (3,15 ko)

Voir les différences:

Subject: [PATCH] attribute_kinds: add person title

Default presentation is two radio buttons with mister and mrs.
 src/authentic2/app_settings.py                 |  1 +
 src/authentic2/attribute_kinds.py              | 18 +++++++++++++++++-
 src/authentic2/locale/fr/LC_MESSAGES/django.po | 14 ++++++++++++++
 3 files changed, 32 insertions(+), 1 deletion(-)
src/authentic2/app_settings.py
155 155
            definition='exponential backoff maximum duration as seconds until '
156 156
            'time until next try after a login failure'),
157 157
    A2_VERIFY_SSL=Setting(default=True, definition='Verify SSL certificate in HTTP requests'),
158
    A2_ATTRIBUTE_KIND_TITLE_CHOICES=Setting(default=(), definition='Choices for the title attribute kind'),
158 159
)
159 160

  
160 161
app_settings = AppSettings(default_settings)
src/authentic2/attribute_kinds.py
6 6
from django import forms
7 7
from django.core.exceptions import ValidationError
8 8
from django.core.validators import RegexValidator
9
from django.utils.translation import ugettext_lazy as _
9
from django.utils.translation import ugettext_lazy as _, pgettext_lazy
10 10
from django.utils.functional import allow_lazy
11 11
from django.template.defaultfilters import capfirst
12 12

  
......
15 15

  
16 16
capfirst = allow_lazy(capfirst, unicode)
17 17

  
18
DEFAULT_TITLE_CHOICES = (
19
    pgettext_lazy('title', 'Mrs'),
20
    pgettext_lazy('title', 'Mr'),
21
)
22

  
23
def get_title_choices():
24
    return app_settings.A2_ATTRIBUTE_KIND_TITLE_CHOICES or DEFAULT_TITLE_CHOICES
18 25

  
19 26
DEFAULT_ATTRIBUTE_KINDS = [
20 27
        {
......
22 29
          'name': 'string',
23 30
          'field_class': forms.CharField,
24 31
        },
32
        {
33
          'label': _('title'),
34
          'name': 'title',
35
          'field_class': forms.ChoiceField,
36
          'kwargs': {
37
               'choices': get_title_choices(),
38
               'widget': forms.RadioSelect,
39
          }
40
        }
25 41
]
26 42

  
27 43
def get_attribute_kinds():
src/authentic2/locale/fr/LC_MESSAGES/django.po
94 94
msgid "Username"
95 95
msgstr "Identifiant"
96 96

  
97
#: src/authentic2/attribute_kinds.py:26
98
msgid "title"
99
msgstr "civilité"
100

  
101
#: src/authentic2/attribute_kinds.py:30
102
msgctxt "title"
103
msgid "Mrs"
104
msgstr "Madame"
105

  
97 106
#: src/authentic2/attribute_kinds.py:31
107
msgctxt "title"
108
msgid "Mr"
109
msgstr "Monsieur"
110

  
111
#: src/authentic2/attribute_kinds.py:58
98 112
msgid "SIRET number must contain 14 digits"
99 113
msgstr "Le SIRET doit contenir 14 chiffres"
100 114

  
101
-