diff accounts/models.py @ 623:1555b2c3c7a0

For issue #22, add a UNIQUE contraint on the pending user table's username field.
author Brian Neal <bgneal@gmail.com>
date Wed, 31 Oct 2012 20:06:01 -0500
parents ee87ea74d46b
children
line wrap: on
line diff
--- 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()