Corrections pour sigma
[auf_roa_authentification_backend.git] / auf_roa_authentification_backend / admin.py
1 from django.contrib.auth.forms import UserCreationForm, UserChangeForm
2 from django.contrib.auth.models import User
3 from django.contrib.auth.admin import UserAdmin
4 from django import forms
5 from django.utils.translation import ugettext_lazy as _
6 from django.contrib import admin
7
8 class UserCreationForm(UserCreationForm):
9 username = forms.RegexField(label=_("Username"), max_length=30,
10 regex=r"^[\w\.\-]+$",
11 help_text = _("Required. 30 characters or fewer. Alphanumeric " +
12 "characters only (letters, digits and underscores)."),
13 error_message = _("This value must contain only letters, numbers " +
14 "and underscores."))
15
16 class UserChangeForm(UserChangeForm):
17 username = forms.RegexField(label=_("Username"), max_length=30,
18 regex=r"^[\w\.\-]+$",
19 help_text = _("Required. 30 characters or fewer. Alphanumeric " +
20 "characters only (letters, digits and underscores)."),
21 error_message = _("This value must contain only letters, numbers " +
22 "and underscores."))
23
24 class UserProfileAdmin(UserAdmin):
25 form = UserChangeForm
26 add_form = UserCreationForm
27
28 try:
29 admin.site.unregister(User)
30 except:
31 pass
32 admin.site.register(User, UserProfileAdmin)
33