From ad5596c61c90431d6ef0d73ebc43815d60f04407 Mon Sep 17 00:00:00 2001 From: minhtrannhat Date: Wed, 21 Dec 2022 10:59:46 -0500 Subject: [PATCH] Fix(API): Added email template - Fix the missing logging library --- backend/src/backend/lib/email.py | 2 +- backend/src/backend/run.py | 5 +- backend/src/backend/templates/email.html | 51 +++++++++++++++++++ backend/tests/lib/{email.py => test_email.py} | 4 +- 4 files changed, 58 insertions(+), 4 deletions(-) create mode 100644 backend/src/backend/templates/email.html rename backend/tests/lib/{email.py => test_email.py} (57%) diff --git a/backend/src/backend/lib/email.py b/backend/src/backend/lib/email.py index f7cbaa3..06c5ec1 100644 --- a/backend/src/backend/lib/email.py +++ b/backend/src/backend/lib/email.py @@ -27,7 +27,7 @@ async def send_email( response = await client.post( "https://api.postmarkapp.com/email", json={ - "From": "Tozo ", + "From": "Todo ", "To": to, "Subject": subject, "Tag": template, diff --git a/backend/src/backend/run.py b/backend/src/backend/run.py index da508f6..a48b4be 100644 --- a/backend/src/backend/run.py +++ b/backend/src/backend/run.py @@ -23,6 +23,9 @@ from quart_schema import QuartSchema, RequestSchemaValidationError # PostgreSQL database driver from quart_db import QuartDB +# logging +import logging + app: Quart = Quart(__name__) @@ -34,7 +37,7 @@ auth_manager: AuthManager = AuthManager(app) quart_db = QuartDB(app) rate_limiter: RateLimiter = RateLimiter(app) schema = QuartSchema(app, convert_casing=True) - +logging.basicConfig(level=logging.INFO) app.register_blueprint(control_blueprint) diff --git a/backend/src/backend/templates/email.html b/backend/src/backend/templates/email.html new file mode 100644 index 0000000..9aef3dd --- /dev/null +++ b/backend/src/backend/templates/email.html @@ -0,0 +1,51 @@ + + + + Tozo - email + + + + + + + + + +
+ + + + + + + + + + +
+ {% block welcome %} Hello, {% endblock %} +
+ {% block content %} Example content {% endblock %} +
The Tozo team
+
+ + diff --git a/backend/tests/lib/email.py b/backend/tests/lib/test_email.py similarity index 57% rename from backend/tests/lib/email.py rename to backend/tests/lib/test_email.py index c5e0f61..293fe17 100644 --- a/backend/tests/lib/email.py +++ b/backend/tests/lib/test_email.py @@ -6,5 +6,5 @@ from backend.lib.email import send_email async def test_send_email(app: Quart, caplog: LogCaptureFixture) -> None: async with app.app_context(): - await send_email("member@tozo.dev", "Welcome", "email.html", {}) - assert "Sending email.html to member@tozo.dev" in caplog.text + await send_email("member@minhtrannhat.com", "Welcome", "email.html", {}) + assert "Sending email.html to member@minhtrannhat.com" in caplog.text