diff options
author | Jeremy Kerr <jk@ozlabs.org> | 2008-08-21 13:41:10 +0800 |
---|---|---|
committer | Jeremy Kerr <jk@ozlabs.org> | 2008-08-21 13:41:10 +0800 |
commit | eb6db921938c72c0655ca2e381818a471f99f5fa (patch) | |
tree | 9d66e6962f134d2116aacaeef3b3abe2177156ae /apps/patchwork/models.py | |
parent | ecea8781acaa636186880d24351a6b712d4d3ce5 (diff) | |
download | patchwork-eb6db921938c72c0655ca2e381818a471f99f5fa.tar.bz2 patchwork-eb6db921938c72c0655ca2e381818a471f99f5fa.tar.xz |
Implement confirmation emails.
To do this, we need to allow sucessive requests for the same
confirmation URL.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Diffstat (limited to 'apps/patchwork/models.py')
-rw-r--r-- | apps/patchwork/models.py | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/apps/patchwork/models.py b/apps/patchwork/models.py index f6943fc..7eb28d0 100644 --- a/apps/patchwork/models.py +++ b/apps/patchwork/models.py @@ -145,8 +145,12 @@ class RegistrationRequest(models.Model): email = models.CharField(max_length = 200, unique = True) password = models.CharField(max_length = 200) key = models.CharField(max_length = 32, default = _confirm_key) + date = models.DateTimeField(default=datetime.datetime.now) + active = models.BooleanField(default = True) def create_user(self): + if not self.active: + return user = User.objects.create_user(self.username, self.email, self.password) user.first_name = self.first_name @@ -154,7 +158,8 @@ class RegistrationRequest(models.Model): user.save() profile = UserProfile(user = user) profile.save() - self.delete() + self.active = False + self.save() # link a person to this user. if none exists, create. person = None @@ -176,10 +181,13 @@ class RegistrationRequest(models.Model): class UserPersonConfirmation(models.Model): user = models.ForeignKey(User) email = models.CharField(max_length = 200) - date = models.DateTimeField(default=datetime.datetime.now) key = models.CharField(max_length = 32, default = _confirm_key) + date = models.DateTimeField(default=datetime.datetime.now) + active = models.BooleanField(default = True) def confirm(self): + if not self.active: + return person = None try: person = Person.objects.get(email = self.email) @@ -190,6 +198,7 @@ class UserPersonConfirmation(models.Model): person.link_to_user(self.user) person.save() + self.active = False class Admin: |