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):
|
203 | 203 | |
204 | 204 | Username and password are required. Other fields are optional. |
205 | 205 | """ |
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")) |
207 | 207 | first_name = models.CharField(_('first name'), max_length=30, blank=True) |
208 | 208 | last_name = models.CharField(_('last name'), max_length=30, blank=True) |
209 | 209 | email = models.EmailField(_('e-mail address'), blank=True) |
… |
… |
class User(models.Model):
|
216 | 216 | groups = models.ManyToManyField(Group, verbose_name=_('groups'), blank=True, |
217 | 217 | help_text=_("In addition to the permissions manually assigned, this user will also get all permissions granted to each group he/she is in.")) |
218 | 218 | user_permissions = models.ManyToManyField(Permission, verbose_name=_('user permissions'), blank=True) |
| 219 | site = models.ForeignKey('sites.Site', null=True, default=None) |
219 | 220 | objects = UserManager() |
220 | 221 | |
221 | 222 | class Meta: |
222 | 223 | verbose_name = _('user') |
223 | 224 | verbose_name_plural = _('users') |
| 225 | unique_together = ('username', 'site') |
224 | 226 | |
225 | 227 | def __unicode__(self): |
226 | 228 | return self.username |