Files
RosterChief/templates/account/email/password_reset_key_message.html
Bernard Siebens 67841491a6 Fix mismatched fallback text colour on the initials badge/button
The initials badge and reset button hardcoded two independent
fallback literals -- a background (#ec4899 / #0ea5e9) and a text
colour (#ffffff) -- that were only ever chosen together for a club's
own colour via Club._content_color_for. #ffffff on #ec4899 or
#0ea5e9 actually contrasts worse than black by the same WCAG formula
the app already uses elsewhere (verified: 6.4:1 vs 3.3:1, and 7.6:1
vs 2.8:1). Added a contrast_color filter so the text colour is always
derived from whatever background hex is actually in play -- real
club colour or fallback alike -- instead of a second, independently
guessed literal that can silently drift out of sync with the first.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-12 09:50:07 +02:00

79 lines
4.3 KiB
HTML

{% extends "email/_base.html" %}
{% load i18n club_email %}
{% comment %}
allauth's DefaultAccountAdapter.render_mail looks for
"<template_prefix>_message.<TEMPLATE_EXTENSION>" (TEMPLATE_EXTENSION
defaults to "html", unset in this project) next to the .txt template it
already renders, and attaches it as the HTML alternative automatically --
no Python override needed, see allauth.account.adapter.render_mail.
Context comes from allauth.account.internal.flows.password_reset
.request_password_reset() plus DefaultAccountAdapter.send_mail: user,
password_reset_url, uid, key, request, current_site, email, and username
only when ACCOUNT_LOGIN_METHODS includes "username" (it doesn't here, see
rosterchief/settings.py -- login is email-only -- but the check is kept for
parity with the .txt template in case that ever changes).
render_to_string is called with the real `request`
(allauth.account.adapter.render_mail passes `context.request`), so this
picks up club.context_processors.branding like any other page: `club` is
set when the reset was requested on a club subdomain, None on the base
domain (e.g. a platform control-panel user). Both cases must render
something sensible -- a password reset is exactly the kind of email that
still has to work with no club in play.
{% endcomment %}
{% block title %}{% trans "Reset your password" %}{% endblock title %}
{% block preheader %}{% trans "Use this link to choose a new password. If you didn't request this, you can ignore this email." %}{% endblock preheader %}
{% block header %}
{% if club %}
{% absolute_media_url club.logo as logo_url %}
<table role="presentation" cellpadding="0" cellspacing="0" border="0">
<tr>
<td valign="middle">
{% if club.logo %}
<img src="{{ logo_url }}" alt="{{ club.name }}" width="48" height="48" style="display:block; width:48px; height:48px; border-radius:24px; object-fit:contain; background-color:#f3f4f6;">
{% else %}
<table role="presentation" cellpadding="0" cellspacing="0" border="0" width="48" style="width:48px;">
<tr>
<td align="center" valign="middle" width="48" height="48" bgcolor="{{ club.secondary_color|default:"#ec4899" }}" style="width:48px; height:48px; border-radius:24px; background-color:{{ club.secondary_color|default:"#ec4899" }}; color:{{ club.secondary_color|default:"#ec4899"|contrast_color }}; font-family: Arial, Helvetica, sans-serif; font-size:16px; font-weight:bold;">
{{ club.initials }}
</td>
</tr>
</table>
{% endif %}
</td>
<td style="padding-left:14px;" valign="middle">
<span style="font-family: Arial, Helvetica, sans-serif; font-size:18px; font-weight:bold; color:#111827;">{{ club.name }}</span>
</td>
</tr>
</table>
{% else %}
<span style="font-family: Arial, Helvetica, sans-serif; font-size:20px; font-weight:bold; color:#111827; letter-spacing:0.02em;">Roster<span style="color:#0ea5e9;">Chief</span></span>
{% endif %}
{% endblock header %}
{% block content %}
<p style="margin:0 0 20px 0;">{% trans "You're receiving this email because you or someone else has requested a password reset for your user account. It can be safely ignored if you did not request one." %}</p>
{% trans "Reset your password" as reset_label %}
{% include "email/_button.html" with href=password_reset_url label=reset_label bg=club.primary_color|default:"#0ea5e9" fg=club.primary_color|default:"#0ea5e9"|contrast_color %}
{% if username %}
<p style="margin:0;">{% blocktrans %}In case you forgot, your username is {{ username }}.{% endblocktrans %}</p>
{% endif %}
{% endblock content %}
{% block footer %}
<p style="margin:0;">
{% if club %}
{% blocktrans with club=club.name %}Sent by {{ club }}, powered by RosterChief.{% endblocktrans %}
{% else %}
{% blocktrans with site_name=current_site.name %}Sent by {{ site_name }}.{% endblocktrans %}
{% endif %}
</p>
{% endblock footer %}