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()) )
def test_bad_input(self): mv = DonationMailView() self.assertFalse(mv.send(None))
def test_no_email_addr(self): don = Donation.objects.create(donator_name="Frank", donator_email="") mv = DonationMailView() self.assertFalse(mv.send(don))
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)