mirror of https://github.com/django/django.git
Improved formatting of auth model fields.
This commit is contained in:
parent
fe914341c8
commit
72f6513eba
|
@ -110,8 +110,11 @@ class Group(models.Model):
|
||||||
messages.
|
messages.
|
||||||
"""
|
"""
|
||||||
name = models.CharField(_('name'), max_length=80, unique=True)
|
name = models.CharField(_('name'), max_length=80, unique=True)
|
||||||
permissions = models.ManyToManyField(Permission,
|
permissions = models.ManyToManyField(
|
||||||
verbose_name=_('permissions'), blank=True)
|
Permission,
|
||||||
|
verbose_name=_('permissions'),
|
||||||
|
blank=True,
|
||||||
|
)
|
||||||
|
|
||||||
objects = GroupManager()
|
objects = GroupManager()
|
||||||
|
|
||||||
|
@ -197,18 +200,33 @@ class PermissionsMixin(models.Model):
|
||||||
A mixin class that adds the fields and methods necessary to support
|
A mixin class that adds the fields and methods necessary to support
|
||||||
Django's Group and Permission model using the ModelBackend.
|
Django's Group and Permission model using the ModelBackend.
|
||||||
"""
|
"""
|
||||||
is_superuser = models.BooleanField(_('superuser status'), default=False,
|
is_superuser = models.BooleanField(
|
||||||
help_text=_('Designates that this user has all permissions without '
|
_('superuser status'),
|
||||||
'explicitly assigning them.'))
|
default=False,
|
||||||
groups = models.ManyToManyField(Group, verbose_name=_('groups'),
|
help_text=_(
|
||||||
blank=True, help_text=_('The groups this user belongs to. A user will '
|
'Designates that this user has all permissions without '
|
||||||
'get all permissions granted to each of '
|
'explicitly assigning them.'
|
||||||
'their groups.'),
|
),
|
||||||
related_name="user_set", related_query_name="user")
|
)
|
||||||
user_permissions = models.ManyToManyField(Permission,
|
groups = models.ManyToManyField(
|
||||||
verbose_name=_('user permissions'), blank=True,
|
Group,
|
||||||
|
verbose_name=_('groups'),
|
||||||
|
blank=True,
|
||||||
|
help_text=_(
|
||||||
|
'The groups this user belongs to. A user will get all permissions '
|
||||||
|
'granted to each of their groups.'
|
||||||
|
),
|
||||||
|
related_name="user_set",
|
||||||
|
related_query_name="user",
|
||||||
|
)
|
||||||
|
user_permissions = models.ManyToManyField(
|
||||||
|
Permission,
|
||||||
|
verbose_name=_('user permissions'),
|
||||||
|
blank=True,
|
||||||
help_text=_('Specific permissions for this user.'),
|
help_text=_('Specific permissions for this user.'),
|
||||||
related_name="user_set", related_query_name="user")
|
related_name="user_set",
|
||||||
|
related_query_name="user",
|
||||||
|
)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
abstract = True
|
abstract = True
|
||||||
|
@ -274,27 +292,38 @@ class AbstractUser(AbstractBaseUser, PermissionsMixin):
|
||||||
|
|
||||||
Username, password and email are required. Other fields are optional.
|
Username, password and email are required. Other fields are optional.
|
||||||
"""
|
"""
|
||||||
username = models.CharField(_('username'), max_length=30, unique=True,
|
username = models.CharField(
|
||||||
help_text=_('Required. 30 characters or fewer. Letters, digits and '
|
_('username'),
|
||||||
'@/./+/-/_ only.'),
|
max_length=30,
|
||||||
|
unique=True,
|
||||||
|
help_text=_('Required. 30 characters or fewer. Letters, digits and @/./+/-/_ only.'),
|
||||||
validators=[
|
validators=[
|
||||||
validators.RegexValidator(r'^[\w.@+-]+$',
|
validators.RegexValidator(
|
||||||
_('Enter a valid username. '
|
r'^[\w.@+-]+$',
|
||||||
'This value may contain only letters, numbers '
|
_('Enter a valid username. This value may contain only '
|
||||||
'and @/./+/-/_ characters.'), 'invalid'),
|
'letters, numbers ' 'and @/./+/-/_ characters.')
|
||||||
|
),
|
||||||
],
|
],
|
||||||
error_messages={
|
error_messages={
|
||||||
'unique': _("A user with that username already exists."),
|
'unique': _("A user with that username already exists."),
|
||||||
})
|
},
|
||||||
|
)
|
||||||
first_name = models.CharField(_('first name'), max_length=30, blank=True)
|
first_name = models.CharField(_('first name'), max_length=30, blank=True)
|
||||||
last_name = models.CharField(_('last name'), max_length=30, blank=True)
|
last_name = models.CharField(_('last name'), max_length=30, blank=True)
|
||||||
email = models.EmailField(_('email address'), blank=True)
|
email = models.EmailField(_('email address'), blank=True)
|
||||||
is_staff = models.BooleanField(_('staff status'), default=False,
|
is_staff = models.BooleanField(
|
||||||
help_text=_('Designates whether the user can log into this admin '
|
_('staff status'),
|
||||||
'site.'))
|
default=False,
|
||||||
is_active = models.BooleanField(_('active'), default=True,
|
help_text=_('Designates whether the user can log into this admin site.'),
|
||||||
help_text=_('Designates whether this user should be treated as '
|
)
|
||||||
'active. Unselect this instead of deleting accounts.'))
|
is_active = models.BooleanField(
|
||||||
|
_('active'),
|
||||||
|
default=True,
|
||||||
|
help_text=_(
|
||||||
|
'Designates whether this user should be treated as active. '
|
||||||
|
'Unselect this instead of deleting accounts.'
|
||||||
|
),
|
||||||
|
)
|
||||||
date_joined = models.DateTimeField(_('date joined'), default=timezone.now)
|
date_joined = models.DateTimeField(_('date joined'), default=timezone.now)
|
||||||
|
|
||||||
objects = UserManager()
|
objects = UserManager()
|
||||||
|
|
Loading…
Reference in New Issue