fix: use string budget in email service instead of float
The budget field is stored as a string (e.g., '$25-50'), not a number. Updated EmailService.send_registration_confirmation() to accept budget as a string and display it directly in the email. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -136,7 +136,7 @@ def register(slug: str):
|
|||||||
magic_link_url=magic_link_url,
|
magic_link_url=magic_link_url,
|
||||||
exchange_name=exchange.name,
|
exchange_name=exchange.name,
|
||||||
exchange_description=exchange.description,
|
exchange_description=exchange.description,
|
||||||
budget_amount=float(exchange.budget.replace("$", "")),
|
budget=exchange.budget,
|
||||||
gift_exchange_date=exchange.exchange_date.strftime("%Y-%m-%d"),
|
gift_exchange_date=exchange.exchange_date.strftime("%Y-%m-%d"),
|
||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ class EmailService:
|
|||||||
magic_link_url: str,
|
magic_link_url: str,
|
||||||
exchange_name: str,
|
exchange_name: str,
|
||||||
exchange_description: str | None,
|
exchange_description: str | None,
|
||||||
budget_amount: float,
|
budget: str,
|
||||||
gift_exchange_date: str,
|
gift_exchange_date: str,
|
||||||
) -> Any:
|
) -> Any:
|
||||||
"""Send registration confirmation email with magic link.
|
"""Send registration confirmation email with magic link.
|
||||||
@@ -136,7 +136,7 @@ class EmailService:
|
|||||||
magic_link_url: Full URL with magic token
|
magic_link_url: Full URL with magic token
|
||||||
exchange_name: Name of the exchange
|
exchange_name: Name of the exchange
|
||||||
exchange_description: Description of the exchange (optional)
|
exchange_description: Description of the exchange (optional)
|
||||||
budget_amount: Budget amount
|
budget: Budget description (e.g., "$25-50")
|
||||||
gift_exchange_date: Date of gift exchange
|
gift_exchange_date: Date of gift exchange
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
@@ -159,7 +159,7 @@ class EmailService:
|
|||||||
{description_html}
|
{description_html}
|
||||||
<h3>Exchange Details</h3>
|
<h3>Exchange Details</h3>
|
||||||
<ul>
|
<ul>
|
||||||
<li><strong>Budget:</strong> ${budget_amount:.0f}</li>
|
<li><strong>Budget:</strong> {budget}</li>
|
||||||
<li><strong>Gift Exchange Date:</strong> {gift_exchange_date}</li>
|
<li><strong>Gift Exchange Date:</strong> {gift_exchange_date}</li>
|
||||||
</ul>
|
</ul>
|
||||||
<h3>Access Your Dashboard</h3>
|
<h3>Access Your Dashboard</h3>
|
||||||
|
|||||||
@@ -167,7 +167,7 @@ class TestEmailService:
|
|||||||
magic_link_url="https://example.com/magic/abc123",
|
magic_link_url="https://example.com/magic/abc123",
|
||||||
exchange_name="Secret Santa 2025",
|
exchange_name="Secret Santa 2025",
|
||||||
exchange_description="Annual office Secret Santa",
|
exchange_description="Annual office Secret Santa",
|
||||||
budget_amount=50,
|
budget="$25-50",
|
||||||
gift_exchange_date="2025-12-20",
|
gift_exchange_date="2025-12-20",
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -179,7 +179,7 @@ class TestEmailService:
|
|||||||
assert "John Doe" in call_args["html_body"]
|
assert "John Doe" in call_args["html_body"]
|
||||||
assert "https://example.com/magic/abc123" in call_args["html_body"]
|
assert "https://example.com/magic/abc123" in call_args["html_body"]
|
||||||
assert "Annual office Secret Santa" in call_args["html_body"]
|
assert "Annual office Secret Santa" in call_args["html_body"]
|
||||||
assert "$50" in call_args["html_body"]
|
assert "$25-50" in call_args["html_body"]
|
||||||
assert "2025-12-20" in call_args["html_body"]
|
assert "2025-12-20" in call_args["html_body"]
|
||||||
|
|
||||||
def test_dev_mode_logs_magic_link_url(self, app, caplog):
|
def test_dev_mode_logs_magic_link_url(self, app, caplog):
|
||||||
|
|||||||
Reference in New Issue
Block a user