summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdvinas Jurevicius <ikonitas@gmail.com>2015-05-02 18:59:00 +0100
committerTim Graham <timograham@gmail.com>2015-05-05 12:59:19 -0400
commit72f6513ebaa7a3fd43c26300e9a8c430dc07cdb5 (patch)
tree7380f642e1f837a46ea6411e53fa7105b5c3525f
parentfe914341c83b37fd6aa8fd85620cf49dd2328ab0 (diff)
Improved formatting of auth model fields.
-rw-r--r--django/contrib/auth/models.py83
1 files changed, 56 insertions, 27 deletions
diff --git a/django/contrib/auth/models.py b/django/contrib/auth/models.py
index 84088f6525..aa0669ffe0 100644
--- a/django/contrib/auth/models.py
+++ b/django/contrib/auth/models.py
@@ -110,8 +110,11 @@ class Group(models.Model):
messages.
"""
name = models.CharField(_('name'), max_length=80, unique=True)
- permissions = models.ManyToManyField(Permission,
- verbose_name=_('permissions'), blank=True)
+ permissions = models.ManyToManyField(
+ Permission,
+ verbose_name=_('permissions'),
+ blank=True,
+ )
objects = GroupManager()
@@ -197,18 +200,33 @@ class PermissionsMixin(models.Model):
A mixin class that adds the fields and methods necessary to support
Django's Group and Permission model using the ModelBackend.
"""
- is_superuser = models.BooleanField(_('superuser status'), default=False,
- help_text=_('Designates that this user has all permissions without '
- 'explicitly assigning them.'))
- groups = models.ManyToManyField(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,
+ is_superuser = models.BooleanField(
+ _('superuser status'),
+ default=False,
+ help_text=_(
+ 'Designates that this user has all permissions without '
+ 'explicitly assigning them.'
+ ),
+ )
+ groups = models.ManyToManyField(
+ 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.'),
- related_name="user_set", related_query_name="user")
+ related_name="user_set",
+ related_query_name="user",
+ )
class Meta:
abstract = True
@@ -274,27 +292,38 @@ class AbstractUser(AbstractBaseUser, PermissionsMixin):
Username, password and email are required. Other fields are optional.
"""
- username = models.CharField(_('username'), max_length=30, unique=True,
- help_text=_('Required. 30 characters or fewer. Letters, digits and '
- '@/./+/-/_ only.'),
+ username = models.CharField(
+ _('username'),
+ max_length=30,
+ unique=True,
+ help_text=_('Required. 30 characters or fewer. Letters, digits and @/./+/-/_ only.'),
validators=[
- validators.RegexValidator(r'^[\w.@+-]+$',
- _('Enter a valid username. '
- 'This value may contain only letters, numbers '
- 'and @/./+/-/_ characters.'), 'invalid'),
+ validators.RegexValidator(
+ r'^[\w.@+-]+$',
+ _('Enter a valid username. This value may contain only '
+ 'letters, numbers ' 'and @/./+/-/_ characters.')
+ ),
],
error_messages={
'unique': _("A user with that username already exists."),
- })
+ },
+ )
first_name = models.CharField(_('first name'), max_length=30, blank=True)
last_name = models.CharField(_('last name'), max_length=30, blank=True)
email = models.EmailField(_('email address'), blank=True)
- is_staff = models.BooleanField(_('staff status'), default=False,
- help_text=_('Designates whether the user can log into this admin '
- 'site.'))
- is_active = models.BooleanField(_('active'), default=True,
- help_text=_('Designates whether this user should be treated as '
- 'active. Unselect this instead of deleting accounts.'))
+ is_staff = models.BooleanField(
+ _('staff status'),
+ default=False,
+ help_text=_('Designates whether the user can log into this admin site.'),
+ )
+ 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)
objects = UserManager()