From 7f99b63d750d425c3d9c8685df06a278debb6ab3 Mon Sep 17 00:00:00 2001 From: Hostea dashboard Date: Sun, 4 Sep 2022 18:19:45 +0530 Subject: [PATCH] fix: don't send pre-payment notification email closes: https://gitea.gna.org/Hostea/dashboard/issues/49 --- accounts/tests.py | 8 +++++-- .../billing/emails/payment-notification.txt | 14 ----------- billing/tests.py | 11 --------- billing/utils.py | 23 ------------------- 4 files changed, 6 insertions(+), 50 deletions(-) delete mode 100644 billing/templates/billing/emails/payment-notification.txt diff --git a/accounts/tests.py b/accounts/tests.py index 95d7840..06cd182 100644 --- a/accounts/tests.py +++ b/accounts/tests.py @@ -77,7 +77,9 @@ class LoginTest(TestCase): Tests if login template renders """ resp = self.client.get(reverse("accounts.login")) - self.assertEqual(b"A free forge ecosystem for free developers" in resp.content, True) + self.assertEqual( + b"A free forge ecosystem for free developers" in resp.content, True + ) def test_login_works(self): """ @@ -234,7 +236,9 @@ class RegistrationTest(TestCase): Tests if register template renders """ resp = self.client.get(reverse("accounts.register")) - self.assertEqual(b"A free forge ecosystem for free developers." in resp.content, True) + self.assertEqual( + b"A free forge ecosystem for free developers." in resp.content, True + ) def test_register_works(self): """ diff --git a/billing/templates/billing/emails/payment-notification.txt b/billing/templates/billing/emails/payment-notification.txt deleted file mode 100644 index cd43a48..0000000 --- a/billing/templates/billing/emails/payment-notification.txt +++ /dev/null @@ -1,14 +0,0 @@ -Hello {{ username }}! - -An invoice is generated for your Hostea VM {{ payment.instance_name }}. - -- Configuration: {{payment.instance_configuration_id.name}} -- Invoice generated on: {{payment.date.month}}/{{payment.date.day}}/{{payment.date.year}} -- Total Amount: {{payment.total}} {{payment.currency|upper}} - -To pay, please click the link below: - -{{ link }} - -Cheers, -Hostea team diff --git a/billing/tests.py b/billing/tests.py index 071764a..42d7ca3 100644 --- a/billing/tests.py +++ b/billing/tests.py @@ -121,17 +121,6 @@ class BillingTest(TestCase): True, ) - invoice_generated_mail = mail.outbox.pop() - self.assertEqual( - all( - [ - invoice_generated_mail.to[0] == self.email, - "An invoice is generated" in invoice_generated_mail.body, - ] - ), - True, - ) - ## payment failure page; no real functionality but user is redirected here # by stripe if payment is successful resp = c.get(reverse("billing.invoice.fail", args=(payment.public_ref,))) diff --git a/billing/utils.py b/billing/utils.py index 349fd4c..8e050e2 100644 --- a/billing/utils.py +++ b/billing/utils.py @@ -98,27 +98,4 @@ def generate_invoice(instance: Instance) -> Payment: instance=instance, ) - invoice_link = get_invoice_link(payment=payment) - - ctx = { - "username": instance.owned_by.username, - "link": invoice_link, - "payment": payment, - } - - body = render_to_string( - "billing/emails/payment-notification.txt", - context=ctx, - ) - - email = instance.owned_by.email - sender = settings.DEFAULT_FROM_EMAIL - - send_mail( - subject="[Hostea] An invoice is generated for your Hostea VM", - message=body, - from_email=f"No reply Hostea<{sender}>", # TODO read from settings.py - recipient_list=[email], - ) - return payment