-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Luke Sneeringer
committed
Feb 26, 2012
1 parent
299bc78
commit 1a3de1a
Showing
10 changed files
with
104 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,29 @@ | ||
from django import forms | ||
from django.contrib.auth.forms import UserCreationForm | ||
from wedding.reservations.models import Invitation | ||
|
||
|
||
class RegistrationForm(UserCreationForm): | ||
code = forms.CharField( | ||
help_text='Enter the code provided to you on your invitation response card. Case insensitive.', | ||
token = forms.CharField( | ||
help_text='Enter the token provided to you on your invitation response card. Case insensitive.', | ||
max_length=11, | ||
) | ||
) | ||
|
||
def clean_token(self): | ||
"""Ensure validity of the user's registration token.""" | ||
|
||
# transform this code to all lowercase, and remove the hyphen | ||
# if it's present | ||
token = self.cleaned_data['token'].replace('-', '').lower() | ||
|
||
# if the token is not in the database, then error out | ||
if Invitation.objects.filter(token=token).count() == 0: | ||
raise forms.ValidationError, 'That token was not found.' | ||
|
||
# another possibility is that the token has already been used--test for this; | ||
# don't allow multiple accounts on the same invitation | ||
if Invitation.objects.filter(token=token).exclude(user=None).count() > 0: | ||
raise forms.ValidationError, 'There is already a user account registered for this token.' | ||
|
||
# okay, we're good to go... | ||
return token |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,15 @@ | ||
from django.dispatch import receiver | ||
from django.db.models.signals import pre_save | ||
from random import choice | ||
from wedding.reservations.models import Invitation | ||
from wedding.reservations.models import Invitation, Invitee | ||
|
||
|
||
@receiver(pre_save, sender=Invitation) | ||
def on_invitation_save(sender, instance, **kwargs): | ||
if not instance.token: | ||
instance.token = ''.join([choice('23456789abcdefghjkmnpqrstuvwxyz') for i in range(0,8)]) | ||
instance.token = ''.join([choice('23456789abcdefghjkmnpqrstuvwxyz') for i in range(0,8)]) | ||
|
||
@receiver(pre_save, sender=Invitee) | ||
def on_invitee_save(sender, instance, **kwargs): | ||
if not instance.nickname: | ||
instance.nickname = instance.first_name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters