Skip to content

Commit

Permalink
add basic email field in
Browse files Browse the repository at this point in the history
  • Loading branch information
tswicegood committed Apr 10, 2012
1 parent ed22306 commit d94713b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions armstrong/apps/donations/models.py
Expand Up @@ -28,6 +28,7 @@ class Donor(models.Model):
related_name="mailing_addresses", null=True, blank=True)
# TODO: Make sure form widget is USPhoneNumberField
phone = models.CharField(max_length=10, null=True, blank=True)
email = models.EmailField(null=True, blank=True)

def save(self, **kwargs):
if self.user:
Expand Down
8 changes: 7 additions & 1 deletion armstrong/apps/donations/tests/forms.py
Expand Up @@ -51,13 +51,19 @@ def test_saves_user_if_user_pk_is_submitted(self):
self.assertEqual(user.pk, donation.donor.user.pk)

def test_behaves_if_an_empty_user_pk_is_given(self):
user = self.random_user
data = self.get_base_random_data()
data["user_pk"] = ""
form = forms.BaseDonationForm(data)
donation = form.save()
self.assertEqual(None, donation.donor.user)

def test_saves_email_if_submitted(self):
data = self.get_base_random_data()
data["email"] = "bob@example.com"
form = forms.BaseDonationForm(data)
donation = form.save()
self.assertEqual("bob@example.com", donation.donor.email)

def test_saves_user_if_user_pk_is_submitted_on_prefixed_form(self):
prefix = "prefix%d" % random.randint(100, 200)
user = self.random_user
Expand Down

0 comments on commit d94713b

Please sign in to comment.