feat(newsletter): Add subscription confirmation email functionality
All checks were successful
CI / test (3.11) (push) Successful in 9m26s
CI / build-image (push) Successful in 49s

- Implemented `send_subscription_confirmation` function to send a confirmation email upon subscription.
- Added a default HTML template for the confirmation email in settings.
- Updated the newsletter management page to handle subscription and unsubscription actions.
- Created new templates for embedding contact and newsletter forms.
- Added styles for the new templates and unified CSS styles across the application.
- Updated tests to reflect changes in the newsletter management API endpoints.
This commit is contained in:
2025-10-30 12:38:26 +01:00
parent f7695be8ef
commit 56840ac313
24 changed files with 897 additions and 449 deletions

View File

@@ -76,13 +76,13 @@ def test_newsletter_update_email_not_found(client):
def test_newsletter_manage_page_get(client):
resp = client.get("/api/newsletter/manage")
resp = client.get("/newsletter/manage")
assert resp.status_code == 200
assert b"Newsletter Subscription Management" in resp.data
def test_newsletter_manage_subscribe(client):
resp = client.post("/api/newsletter/manage",
resp = client.post("/newsletter/manage",
data={"email": "manage@example.com", "action": "subscribe"})
assert resp.status_code == 200
assert b"Successfully subscribed" in resp.data
@@ -90,29 +90,29 @@ def test_newsletter_manage_subscribe(client):
def test_newsletter_manage_unsubscribe(client):
# Subscribe first
client.post("/api/newsletter/manage",
client.post("/newsletter/manage",
data={"email": "manage@example.com", "action": "subscribe"})
# Unsubscribe
resp = client.post("/api/newsletter/manage",
resp = client.post("/newsletter/manage",
data={"email": "manage@example.com", "action": "unsubscribe"})
assert resp.status_code == 200
assert b"Successfully unsubscribed" in resp.data
assert b"Unsubscription Confirmed" in resp.data
def test_newsletter_manage_update(client):
# Subscribe first
client.post("/api/newsletter/manage",
client.post("/newsletter/manage",
data={"email": "old@example.com", "action": "subscribe"})
# Update
resp = client.post("/api/newsletter/manage", data={
"old_email": "old@example.com", "new_email": "updated@example.com", "action": "update"})
resp = client.post("/newsletter/manage", data={
"old_email": "old@example.com", "email": "updated@example.com", "action": "update"})
assert resp.status_code == 200
# Check that some success message is displayed
assert b"success" in resp.data.lower() or b"updated" in resp.data.lower()
assert b"updated successfully" in resp.data.lower()
def test_newsletter_manage_invalid_email(client):
resp = client.post("/api/newsletter/manage",
resp = client.post("/newsletter/manage",
data={"email": "invalid-email", "action": "subscribe"})
assert resp.status_code == 200
assert b"Please enter a valid email address" in resp.data