diff --git a/src/mailer.py b/src/mailer.py index ff2e182..83d114e 100644 --- a/src/mailer.py +++ b/src/mailer.py @@ -22,7 +22,7 @@ def fetch_todays_birthdays(conn) -> list[dict]: today = date.today() with conn.cursor() as cur: cur.execute( - """SELECT id, account, full_name, birthday + """SELECT id, account, full_name, birthday, organization, photo_url FROM contacts WHERE birthday IS NOT NULL AND MONTH(birthday) = %s @@ -66,7 +66,10 @@ def build_message(birthdays: list[dict]) -> EmailMessage: plain_lines = [f"Heutige Geburtstage ({today.isoformat()}):", ""] for b in birthdays: age = today.year - b["birthday"].year - line = f"- {b['full_name']} (wird {age}, Account: {b['account']})" + date_str = b["birthday"].strftime("%d.%m.") + line = f"- {b['full_name']} ยท {date_str} ยท {age} Jahre" + if b.get("organization"): + line += f" ({b['organization']})" if Config.WEB_URL: line += f" โ†’ {Config.WEB_URL.rstrip('/')}/contacts/{b['id']}" plain_lines.append(line) @@ -77,19 +80,25 @@ def build_message(birthdays: list[dict]) -> EmailMessage: cards_html = "" for b in birthdays: age = today.year - b["birthday"].year + date_str = b["birthday"].strftime("%d.%m.") contact_link = f"{Config.WEB_URL.rstrip('/')}/contacts/{b['id']}" if Config.WEB_URL else "" name_html = f'{b["full_name"]}' if contact_link else b["full_name"] + is_today = b["birthday"].month == today.month and b["birthday"].day == today.day + card_bg = "#fff3cd" if is_today else "#fff" + org_html = f'
{b["organization"]}
' if b.get("organization") else "" + photo_html = "" + if b.get("photo_url"): + photo_html = f'' cards_html += f""" - +
{name_html}
-
Account: {b['account']}
-
-
- ๐ŸŽ‚ wird {age} + {org_html} +
๐ŸŽ‚ {date_str} ยท {age} Jahre
+ {photo_html}