From 534abe296ff687a18ef25515930e5e87d1a9aa0a Mon Sep 17 00:00:00 2001 From: Dan Sahagian <45240763+dansahagian@users.noreply.github.com> Date: Wed, 24 Jul 2024 17:29:44 -0700 Subject: [PATCH] Add reminder and caching scripts for crontab --- .gitignore | 3 ++- bin/cache-current-board | 5 +++++ bin/send-reminders | 5 +++++ fbsurvivor/core/utils/emails.py | 6 ++++-- fbsurvivor/core/utils/reminders.py | 2 +- 5 files changed, 17 insertions(+), 4 deletions(-) create mode 100755 bin/cache-current-board create mode 100755 bin/send-reminders diff --git a/.gitignore b/.gitignore index d9026b1..caf9769 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,5 @@ __pycache__ venv .venv *.pid -.pytest_cache \ No newline at end of file +.pytest_cache +notebook.ipynb \ No newline at end of file diff --git a/bin/cache-current-board b/bin/cache-current-board new file mode 100755 index 0000000..a35e2b0 --- /dev/null +++ b/bin/cache-current-board @@ -0,0 +1,5 @@ +#!/bin/zsh + +cd /opt/fbsurvivor +.venv/bin/python ./manage.py cache_current_board +echo "Board Cached" \ No newline at end of file diff --git a/bin/send-reminders b/bin/send-reminders new file mode 100755 index 0000000..3aa6c2a --- /dev/null +++ b/bin/send-reminders @@ -0,0 +1,5 @@ +#!/bin/zsh + +cd /opt/fbsurvivor +.venv/bin/python ./manage.py send_reminders +echo "Reminders Sent" \ No newline at end of file diff --git a/fbsurvivor/core/utils/emails.py b/fbsurvivor/core/utils/emails.py index 5941d73..97cc969 100644 --- a/fbsurvivor/core/utils/emails.py +++ b/fbsurvivor/core/utils/emails.py @@ -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 @@ -20,3 +20,5 @@ def send_email(subject, recipients, message): conn.sendmail(SMTP_SENDER, recipients, msg.as_string()) finally: conn.quit() + + return None diff --git a/fbsurvivor/core/utils/reminders.py b/fbsurvivor/core/utils/reminders.py index 393c60f..521d97a 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)):