def handle(self, *args, **options):
     mv = DonationMailView()
     for donation in Donation.objects.filter(send_receipt=True).all():
         sent = mv.send(donation)
         if sent:
             donation.send_receipt = False
             donation.save()
             DonationNote.objects.create(
                 donation=donation,
                 author=None,
                 content="Receipt emailed on {}.".format(date.today().isoformat())
             )
예제 #2
0
 def test_bad_input(self):
     mv = DonationMailView()
     self.assertFalse(mv.send(None))
예제 #3
0
 def test_no_email_addr(self):
     don = Donation.objects.create(donator_name="Frank", donator_email="")
     mv = DonationMailView()
     self.assertFalse(mv.send(don))
예제 #4
0
 def test_normal(self):
     don = Donation.objects.create(donator_name="Frank", donator_email="*****@*****.**")
     mv = DonationMailView()
     self.assertTrue(mv.send(don))
     self.assertEqual(len(mail.outbox), 1)
     self.assertEqual(MailView.for_model(Donation), DonationMailView)