Corrections pour sigma
[auf_roa_authentification_backend.git] / auf_roa_authentification_backend / admin.py
CommitLineData
8584ef0b
CR
1from django.contrib.auth.forms import UserCreationForm, UserChangeForm
2from django.contrib.auth.models import User
3from django.contrib.auth.admin import UserAdmin
4from django import forms
5from django.utils.translation import ugettext_lazy as _
6from django.contrib import admin
7
8class UserCreationForm(UserCreationForm):
9 username = forms.RegexField(label=_("Username"), max_length=30,
7024c88f 10 regex=r"^[\w\.\-]+$",
8584ef0b
CR
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
16class UserChangeForm(UserChangeForm):
17 username = forms.RegexField(label=_("Username"), max_length=30,
7024c88f 18 regex=r"^[\w\.\-]+$",
8584ef0b
CR
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
24class UserProfileAdmin(UserAdmin):
25 form = UserChangeForm
26 add_form = UserCreationForm
27
d0d9fa63
CR
28try:
29 admin.site.unregister(User)
30except:
31 pass
8584ef0b
CR
32admin.site.register(User, UserProfileAdmin)
33