# HG changeset patch # User Brian Neal # Date 1351731961 18000 # Node ID 1555b2c3c7a06091169ef3dca23272d5d98604b2 # Parent 91a6a1b5007f1dcbcdbb7058e1652232664262cb For issue #22, add a UNIQUE contraint on the pending user table's username field. diff -r 91a6a1b5007f -r 1555b2c3c7a0 accounts/models.py --- a/accounts/models.py Wed Oct 31 19:10:38 2012 -0500 +++ b/accounts/models.py Wed Oct 31 20:06:01 2012 -0500 @@ -44,12 +44,12 @@ temp_user = User() temp_user.set_password(password) - now = datetime.datetime.now() - pending_user = self.model(None, - username, - email, - temp_user.password, - now, + now = datetime.datetime.now() + pending_user = self.model(None, + username, + email, + temp_user.password, + now, self._make_key()) pending_user.save() @@ -77,11 +77,11 @@ class PendingUser(models.Model): """model for holding users while they go through the email registration cycle""" - username = models.CharField(max_length=30, db_index=True) + username = models.CharField(max_length=30, db_index=True, unique=True) email = models.EmailField() password = models.CharField(max_length=128) date_joined = models.DateTimeField(default=datetime.datetime.now, db_index=True) - key = models.CharField(max_length=20, editable=True) + key = models.CharField(max_length=20) objects = PendingUserManager()