From 0ea11275956d9a6bcce13ac99004050146b568a8 Mon Sep 17 00:00:00 2001 From: jkfinplan Date: Mon, 10 Nov 2025 16:13:05 -0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Improve=20email=20notification=20su?= =?UTF-8?q?bject=20lines=20with=20campground=20details?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add dynamic subject lines to email notifications that include: - Campground/facility name - Booking date - Number of available campsites This makes email notifications more informative and actionable, allowing users to quickly identify the campground and date without opening the email. Changes: - email_notifications.py: Add dynamic subject for campsite notifications - base_search.py: Add dynamic subject for high-availability warning --- camply/notifications/email_notifications.py | 12 +++++++++++- camply/search/base_search.py | 7 ++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/camply/notifications/email_notifications.py b/camply/notifications/email_notifications.py index 44270291..6a89b91f 100755 --- a/camply/notifications/email_notifications.py +++ b/camply/notifications/email_notifications.py @@ -120,4 +120,14 @@ def send_campsites(self, campsites: List[AvailableCampsite], **kwargs) -> None: master_email_body_list.append(composed_message) master_email_body = "\n".join(master_email_body_list) if len(campsites) > 0: - self.send_message(message=master_email_body) + # Create dynamic subject with campground name and date + first_campsite = campsites[0] + campground_name = first_campsite.facility_name + booking_date = first_campsite.booking_date.strftime("%Y-%m-%d") + + if len(campsites) == 1: + subject = f"Campsite Available: {campground_name} - {booking_date}" + else: + subject = f"{len(campsites)} Campsites Available: {campground_name} - {booking_date}" + + self.send_message(message=master_email_body, subject=subject) diff --git a/camply/search/base_search.py b/camply/search/base_search.py index 6b556c62..21be96f2 100644 --- a/camply/search/base_search.py +++ b/camply/search/base_search.py @@ -426,7 +426,12 @@ def _handle_notifications( "Go Get your campsite! 🏕" ) logger.warning(error_message) - notifier.send_message(message=error_message) + # Create subject with campground name and date + first_campsite = logged_campsites[0] + campground_name = first_campsite.facility_name + booking_date = first_campsite.booking_date.strftime("%Y-%m-%d") + subject = f"Lots of Availability ({len(logged_campsites)} sites): {campground_name} - {booking_date}" + notifier.send_message(message=error_message, subject=subject) logged_campsites = logged_campsites[:minimum_first_notify] notifier.send_campsites(campsites=logged_campsites)