Browse files

add basic email field in

  • Loading branch information...
1 parent ed22306 commit d94713b18dad217caa9a19edc8b8b60b36b63013 @tswicegood tswicegood committed Apr 10, 2012
Showing with 8 additions and 1 deletion.
  1. +1 −0 armstrong/apps/donations/models.py
  2. +7 −1 armstrong/apps/donations/tests/forms.py
View
1 armstrong/apps/donations/models.py
@@ -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:
View
8 armstrong/apps/donations/tests/forms.py
@@ -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

0 comments on commit d94713b

Please sign in to comment.