Ticket #15110: add_site_field.patch

File add_site_field.patch, 1.8 KB (added by jorgeecardona, 14 years ago)

Add a site field in user with null=True and default=None, and a new constraint for uniquness between username and site.

  • django/contrib/auth/models.py

    From d18f0d3903ca75578a9883985b439eea17b343fd Mon Sep 17 00:00:00 2001
    From: Jorge Eduardo Cardona <jorgeecardona@gmail.com>
    Date: Tue, 18 Jan 2011 15:57:41 -0500
    Subject: [PATCH] Add site field and constraint for it in auth.User
    
    ---
     django/contrib/auth/models.py |    4 +++-
     1 files changed, 3 insertions(+), 1 deletions(-)
    
    diff --git a/django/contrib/auth/models.py b/django/contrib/auth/models.py
    index ec3af63..f51ba3b 100644
    a b class User(models.Model):  
    203203
    204204    Username and password are required. Other fields are optional.
    205205    """
    206     username = models.CharField(_('username'), max_length=30, unique=True, help_text=_("Required. 30 characters or fewer. Letters, numbers and @/./+/-/_ characters"))
     206    username = models.CharField(_('username'), max_length=30, help_text=_("Required. 30 characters or fewer. Letters, numbers and @/./+/-/_ characters"))
    207207    first_name = models.CharField(_('first name'), max_length=30, blank=True)
    208208    last_name = models.CharField(_('last name'), max_length=30, blank=True)
    209209    email = models.EmailField(_('e-mail address'), blank=True)
    class User(models.Model):  
    216216    groups = models.ManyToManyField(Group, verbose_name=_('groups'), blank=True,
    217217        help_text=_("In addition to the permissions manually assigned, this user will also get all permissions granted to each group he/she is in."))
    218218    user_permissions = models.ManyToManyField(Permission, verbose_name=_('user permissions'), blank=True)
     219    site = models.ForeignKey('sites.Site', null=True, default=None)
    219220    objects = UserManager()
    220221
    221222    class Meta:
    222223        verbose_name = _('user')
    223224        verbose_name_plural = _('users')
     225        unique_together = ('username', 'site')
    224226
    225227    def __unicode__(self):
    226228        return self.username
Back to Top