From 0c49523163fa315a271bdda669ac5846c428cb13 Mon Sep 17 00:00:00 2001 From: Dan Sahagian <45240763+dansahagian@users.noreply.github.com> Date: Thu, 25 Jul 2024 17:02:02 -0700 Subject: [PATCH] Make sending emails more consistent --- fbsurvivor/core/urls.py | 4 ++-- fbsurvivor/core/utils/auth.py | 2 +- fbsurvivor/core/utils/emails.py | 2 +- fbsurvivor/core/utils/reminders.py | 2 +- fbsurvivor/core/views.py | 8 ++------ fbsurvivor/templates/more.html | 4 ++-- 6 files changed, 9 insertions(+), 13 deletions(-) diff --git a/fbsurvivor/core/urls.py b/fbsurvivor/core/urls.py index 9e4d1a1..fd2d426 100644 --- a/fbsurvivor/core/urls.py +++ b/fbsurvivor/core/urls.py @@ -4,7 +4,7 @@ assume, board, board_redirect, - dark_mode, + theme, enter, get_players, logout, @@ -44,7 +44,7 @@ path("payouts/", payouts, name="payouts"), path("rules/", rules, name="rules"), path("seasons/", seasons, name="seasons"), - path("darkmode/", dark_mode, name="dark_mode"), + path("theme/", theme, name="theme"), path("picks/", picks_redirect, name="picks_redirect"), path("picks//", picks, name="picks"), path("picks///", pick, name="pick"), diff --git a/fbsurvivor/core/utils/auth.py b/fbsurvivor/core/utils/auth.py index 563a05f..2ff4a3c 100644 --- a/fbsurvivor/core/utils/auth.py +++ b/fbsurvivor/core/utils/auth.py @@ -101,6 +101,6 @@ def get_season_context(year: int, **kwargs) -> (Season, dict): def send_magic_link(player: Player) -> None: token = create_token(player) - subject = "🏈 Survivor Sign in" + subject = "Survivor Sign in" message = f"Click the link below to signin\n\n{DOMAIN}/enter/{token}" send_email(subject, [player.email], message) diff --git a/fbsurvivor/core/utils/emails.py b/fbsurvivor/core/utils/emails.py index 97cc969..9702a06 100644 --- a/fbsurvivor/core/utils/emails.py +++ b/fbsurvivor/core/utils/emails.py @@ -10,7 +10,7 @@ def send_email(subject, recipients, message) -> None: return None msg = MIMEText(message) - msg["Subject"] = subject + msg["Subject"] = f"🏈 {subject} 🏈" msg["From"] = SMTP_SENDER msg["To"] = SMTP_SENDER diff --git a/fbsurvivor/core/utils/reminders.py b/fbsurvivor/core/utils/reminders.py index 521d97a..b5caf61 100644 --- a/fbsurvivor/core/utils/reminders.py +++ b/fbsurvivor/core/utils/reminders.py @@ -15,7 +15,7 @@ def send_reminders(): if not message: return - subject = f"🏈 Survivor Week {next_week.week_num} Reminder 🏈" + subject = f"Survivor Week {next_week.week_num} Reminder" message = f"Week {next_week.week_num} Locks:\n\n" + message if email_recipients := list(PlayerStatus.objects.for_email_reminders(next_week)): diff --git a/fbsurvivor/core/views.py b/fbsurvivor/core/views.py index ae64507..ce76781 100644 --- a/fbsurvivor/core/views.py +++ b/fbsurvivor/core/views.py @@ -166,7 +166,7 @@ def play(request, year: int, **kwargs): recipient = Player.objects.get(username="DanTheAutomator").email message = f"{player.username} in for {season.year}" - send_email("🏈 New Player! 🏈", [recipient], message) + send_email("Survivor New Player!", [recipient], message) return redirect(reverse("board", args=[year])) @@ -255,7 +255,7 @@ def seasons(request, **kwargs): @authenticate_player -def dark_mode(request, **kwargs): +def theme(request, **kwargs): player = kwargs["player"] player.is_dark_mode = not player.is_dark_mode player.save() @@ -471,8 +471,6 @@ def send_message(request, year, **kwargs): .values_list("email", flat=True) ) - subject = f"🏈 Survivor {subject}" - send_email(subject, recipients, message) return redirect(reverse("board", args=[year])) @@ -495,8 +493,6 @@ def send_message_all(request, year, **kwargs): recipients = list(Player.objects.exclude(email="").values_list("email", flat=True)) - subject = f"🏈 Survivor {subject}" - send_email(subject, recipients, message) return redirect(reverse("board", args=[year])) diff --git a/fbsurvivor/templates/more.html b/fbsurvivor/templates/more.html index 44ab208..f5a70f8 100644 --- a/fbsurvivor/templates/more.html +++ b/fbsurvivor/templates/more.html @@ -4,9 +4,9 @@