def create_code(self, private=True, email=''): code = InvitationCode(private=private) code.save() if private: invitation = Invitation(code=code, email=email, invited=now()) invitation.save() return code
def setUp(self): """Creates a few basic users. Alice is registered but not in beta Bob is registered and in beta (self-signup) Charlie is in beta and has one invite """ self.alice = User.objects.create_user('alice', '*****@*****.**', 'secret') self.bob = User.objects.create_user('bob', '*****@*****.**', 'secret') right_now = now() invitation = Invitation(user=self.bob, invited=right_now, used=right_now) invitation.save() self.charlie = User.objects.create_user('charlie', '*****@*****.**', 'secret') invitation = Invitation(user=self.charlie, invited=right_now, used=right_now) invitation.save() code = InvitationCode(owner=self.charlie) code.save()
def test_using_invite(self): invitation = InvitationCode(email='*****@*****.**') invitation.save() response = self.client.get(reverse('beta_verify_invite', args=[invitation.code])) self.assertRedirects(response, self.signup_url) User.objects.create_user('alice', '*****@*****.**', 'secret') self.client.login(username='******', password='******') response = self.client.get(reverse(self.signup_confirmation_view)) response = self.client.get(reverse('beta_verify_invite', args=[invitation.code])) self.assertRedirects(response, reverse('beta_used'))
def test_using_invite(self): invitation = InvitationCode(email='*****@*****.**') invitation.save() response = self.client.get( reverse('beta_verify_invite', args=[invitation.code])) self.assertRedirects(response, self.signup_url) User.objects.create_user('alice', '*****@*****.**', 'secret') self.client.login(username='******', password='******') response = self.client.get(reverse(self.signup_confirmation_view)) response = self.client.get( reverse('beta_verify_invite', args=[invitation.code])) self.assertRedirects(response, reverse('beta_used'))
def create_invite(self, email): code = InvitationCode(num_invites=0) code.save() invitation = Invitation(code=code, email=email, invited=now()) invitation.save() return invitation
def create_invite(self, email, code_str="foobar"): code = InvitationCode(num_invites=100, code=code_str) code.save() invitation = Invitation(code=code, email=email, invited=now()) invitation.save() return invitation