def email_action(self, request, obj: Model): try: mailview_cls = MailView.for_model(type(obj)) mailview = mailview_cls() html = mailview.get_html(obj) return HttpResponse(html) except RuntimeWarning as e: return HttpResponse(str(e))
def test_normal(self): don = Donation.objects.create(donator_name="Frank", donator_email="*****@*****.**") mv = PhysicalDonationMailView() self.assertTrue(mv.send(don)) self.assertEqual(len(mail.outbox), 1) self.assertEqual(MailView.for_model(Donation), PhysicalDonationMailView)
def email_action(self, request, obj: Model): mailview_cls = MailView.for_model(type(obj)) mailview = mailview_cls() html = mailview.get_html(obj) return HttpResponse(html)
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)