feat(emails): subtask 7 — remove _email_wrap() and _email_button() from worker.py
All 10 email handlers now use render_email_template(). The two legacy inline-HTML helpers are no longer needed and have been removed. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -42,89 +42,6 @@ def _t(key: str, lang: str = "en", **kwargs) -> str:
|
||||
return raw.format(**kwargs) if kwargs else raw
|
||||
|
||||
|
||||
def _email_wrap(body: str, lang: str = "en", preheader: str = "") -> str:
|
||||
"""Wrap email body in a branded layout with inline CSS.
|
||||
|
||||
preheader: hidden preview text shown in email client list views.
|
||||
"""
|
||||
year = utcnow().year
|
||||
tagline = _t("email_footer_tagline", lang)
|
||||
copyright_text = _t("email_footer_copyright", lang, year=year, app_name=config.APP_NAME)
|
||||
# Hidden preheader trick: visible text + invisible padding to prevent
|
||||
# email clients from pulling body text into the preview.
|
||||
preheader_html = ""
|
||||
if preheader:
|
||||
preheader_html = (
|
||||
f'<span style="display:none;font-size:1px;color:#F1F5F9;line-height:1px;'
|
||||
f'max-height:0;max-width:0;opacity:0;overflow:hidden;">'
|
||||
f'{preheader}{"͏ ‌ " * 30}</span>'
|
||||
)
|
||||
return f"""\
|
||||
<!DOCTYPE html>
|
||||
<html lang="{lang}">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<title>{config.APP_NAME}</title>
|
||||
</head>
|
||||
<body style="margin:0;padding:0;background-color:#F1F5F9;font-family:Helvetica,Arial,sans-serif;">
|
||||
{preheader_html}
|
||||
<table width="100%" cellpadding="0" cellspacing="0" style="background-color:#F1F5F9;padding:40px 16px;">
|
||||
<tr><td align="center">
|
||||
<table width="520" cellpadding="0" cellspacing="0" style="max-width:520px;width:100%;background-color:#FFFFFF;border-radius:10px;border:1px solid #E2E8F0;overflow:hidden;">
|
||||
|
||||
<!-- Blue accent border -->
|
||||
<tr><td style="height:3px;background-color:#1D4ED8;font-size:0;line-height:0;"> </td></tr>
|
||||
|
||||
<!-- Wordmark header -->
|
||||
<tr><td style="background-color:#0F172A;padding:24px 36px;">
|
||||
<a href="{config.BASE_URL}" style="text-decoration:none;">
|
||||
<span style="color:#FFFFFF;font-size:18px;font-weight:800;letter-spacing:-0.02em;font-family:'Bricolage Grotesque',Georgia,'Times New Roman',serif;">padelnomics</span>
|
||||
</a>
|
||||
</td></tr>
|
||||
|
||||
<!-- Body -->
|
||||
<tr><td style="padding:36px;color:#334155;font-size:15px;line-height:1.65;">
|
||||
{body}
|
||||
</td></tr>
|
||||
|
||||
<!-- Divider -->
|
||||
<tr><td style="height:1px;background-color:#E2E8F0;"></td></tr>
|
||||
|
||||
<!-- Footer -->
|
||||
<tr><td style="padding:20px 36px;background-color:#F8FAFC;">
|
||||
<p style="margin:0 0 6px;font-size:12px;color:#94A3B8;text-align:center;">
|
||||
<a href="{config.BASE_URL}" style="color:#64748B;text-decoration:none;font-weight:500;">padelnomics.io</a>
|
||||
·
|
||||
{tagline}
|
||||
</p>
|
||||
<p style="margin:0;font-size:11px;color:#CBD5E1;text-align:center;">
|
||||
{copyright_text}
|
||||
</p>
|
||||
</td></tr>
|
||||
|
||||
</table>
|
||||
</td></tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>"""
|
||||
|
||||
|
||||
def _email_button(url: str, label: str) -> str:
|
||||
"""Render a branded CTA button for email.
|
||||
|
||||
Uses display:block for full-width tap target on mobile.
|
||||
"""
|
||||
return (
|
||||
f'<table cellpadding="0" cellspacing="0" width="100%" style="margin:28px 0 8px;">'
|
||||
f'<tr><td style="background-color:#1D4ED8;border-radius:8px;text-align:center;">'
|
||||
f'<a href="{url}" style="display:block;padding:14px 32px;'
|
||||
f'color:#FFFFFF;font-size:15px;font-weight:600;text-decoration:none;'
|
||||
f'letter-spacing:-0.01em;">'
|
||||
f"{label}</a></td></tr></table>"
|
||||
)
|
||||
|
||||
|
||||
def task(name: str):
|
||||
"""Decorator to register a task handler."""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user