Пример #1
0
 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))
Пример #2
0
 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)
Пример #3
0
 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)
Пример #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)