chore: enforce ruff lint and format standards across backend
This commit is contained in:
parent
a8e312a4f8
commit
a6cc585dd0
39 changed files with 459 additions and 559 deletions
|
|
@ -42,8 +42,8 @@ def _page(title: str, intro: str, button_label: str, button_url: str | None, not
|
|||
f'<td bgcolor="{BLUE}" style="border-radius:8px;">'
|
||||
f'<a href="{button_url}" '
|
||||
'style="display:inline-block;padding:12px 28px;font-family:-apple-system,'
|
||||
'Segoe UI,Roboto,Helvetica,Arial,sans-serif;font-size:15px;'
|
||||
'font-weight:600;color:#ffffff;text-decoration:none;'
|
||||
"Segoe UI,Roboto,Helvetica,Arial,sans-serif;font-size:15px;"
|
||||
"font-weight:600;color:#ffffff;text-decoration:none;"
|
||||
f'border-radius:8px;">{button_label}</a></td></tr></table>'
|
||||
)
|
||||
return f"""<!DOCTYPE html>
|
||||
|
|
@ -106,14 +106,10 @@ def _branded_mail(
|
|||
message["From"] = settings.mail_from or settings.contact_to or to_email
|
||||
if settings.contact_to:
|
||||
message["Reply-To"] = settings.contact_to
|
||||
message.set_content(
|
||||
f"{headline}\n\n{intro}\n\n{button_label}:\n{button_url}\n\n{note}\n"
|
||||
)
|
||||
message.set_content(f"{headline}\n\n{intro}\n\n{button_label}:\n{button_url}\n\n{note}\n")
|
||||
# Email-safe HTML: tables + inline CSS; some clients strip <style>, so
|
||||
# the palette is inlined via the f-string constants above.
|
||||
message.add_alternative(
|
||||
_page(headline, intro, button_label, button_url, note), subtype="html"
|
||||
)
|
||||
message.add_alternative(_page(headline, intro, button_label, button_url, note), subtype="html")
|
||||
return message
|
||||
|
||||
|
||||
|
|
@ -149,7 +145,7 @@ def send_magic_link(to_email: str, link: str) -> bool:
|
|||
)
|
||||
try:
|
||||
_send(message)
|
||||
except Exception: # noqa: BLE001 - delivery is best effort, see docstring
|
||||
except (OSError, smtplib.SMTPException):
|
||||
logger.warning("magic-link delivery failed for %s", to_email)
|
||||
return False
|
||||
logger.info("magic link mailed to %s", to_email)
|
||||
|
|
@ -166,8 +162,7 @@ def send_access_notification(request_id: str, name: str, email: str) -> bool:
|
|||
to_email=settings.contact_to,
|
||||
headline="Neue Zugangsanfrage",
|
||||
intro=(
|
||||
f"{name} ({email}) hat Zugang angefordert und wartet auf "
|
||||
"Freigabe in der Verwaltung."
|
||||
f"{name} ({email}) hat Zugang angefordert und wartet auf Freigabe in der Verwaltung."
|
||||
),
|
||||
button_label="In der Verwaltung prüfen",
|
||||
button_url=f"{settings.frontend_url.rstrip('/')}/app/admin",
|
||||
|
|
@ -175,7 +170,7 @@ def send_access_notification(request_id: str, name: str, email: str) -> bool:
|
|||
)
|
||||
try:
|
||||
_send(message)
|
||||
except Exception: # noqa: BLE001 - best effort, request is already stored
|
||||
except (OSError, smtplib.SMTPException):
|
||||
logger.warning("access-request notification failed for %s", request_id)
|
||||
return False
|
||||
return True
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue