Skip to content

Commit

Permalink
Make sending emails more consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
dansahagian committed Jul 26, 2024
1 parent 534abe2 commit 0c49523
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 13 deletions.
4 changes: 2 additions & 2 deletions fbsurvivor/core/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
assume,
board,
board_redirect,
dark_mode,
theme,
enter,
get_players,
logout,
Expand Down Expand Up @@ -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/<int:year>/", picks, name="picks"),
path("picks/<int:year>/<int:week>/", pick, name="pick"),
Expand Down
2 changes: 1 addition & 1 deletion fbsurvivor/core/utils/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
2 changes: 1 addition & 1 deletion fbsurvivor/core/utils/emails.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion fbsurvivor/core/utils/reminders.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)):
Expand Down
8 changes: 2 additions & 6 deletions fbsurvivor/core/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]))

Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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]))
Expand All @@ -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]))
4 changes: 2 additions & 2 deletions fbsurvivor/templates/more.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
<ul>
<li><a href="{% url 'logout' %}">logout</a></li>
{% if player and player.is_dark_mode or is_dark_mode %}
<li><a href="{% url 'dark_mode' %}">light theme</a></li>
<li><a href="{% url 'theme' %}">light theme</a></li>
{% else %}
<li><a href="{% url 'dark_mode' %}">dark theme</a></li>
<li><a href="{% url 'theme' %}">dark theme</a></li>
{% endif %}
<li><a href="{% url 'reminders' %}">reminders</a></li>
<li><a href="{% url 'seasons' %}">seasons</a></li>
Expand Down

0 comments on commit 0c49523

Please sign in to comment.