Skip to content

Commit

Permalink
Add reminder and caching scripts for crontab
Browse files Browse the repository at this point in the history
  • Loading branch information
dansahagian committed Jul 25, 2024
1 parent 7a63689 commit 534abe2
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 4 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ __pycache__
venv
.venv
*.pid
.pytest_cache
.pytest_cache
notebook.ipynb
5 changes: 5 additions & 0 deletions bin/cache-current-board
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/zsh

cd /opt/fbsurvivor
.venv/bin/python ./manage.py cache_current_board
echo "Board Cached"
5 changes: 5 additions & 0 deletions bin/send-reminders
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/zsh

cd /opt/fbsurvivor
.venv/bin/python ./manage.py send_reminders
echo "Reminders Sent"
6 changes: 4 additions & 2 deletions fbsurvivor/core/utils/emails.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
from fbsurvivor.settings import ENV, SMTP_PASSWORD, SMTP_SENDER, SMTP_SERVER, SMTP_USER


def send_email(subject, recipients, message):
def send_email(subject, recipients, message) -> None:
if ENV == "dev":
print(f"\n\nSending Email to {len(recipients)} players...\n{subject}\n\n{message}\n\n")
return
return None

msg = MIMEText(message)
msg["Subject"] = subject
Expand All @@ -20,3 +20,5 @@ def send_email(subject, recipients, message):
conn.sendmail(SMTP_SENDER, recipients, msg.as_string())
finally:
conn.quit()

return None
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

0 comments on commit 534abe2

Please sign in to comment.