From 8b06e580fe66ced0f63e521e5c1a97dba5af6213 Mon Sep 17 00:00:00 2001 From: Marius Robert Macamete Date: Wed, 10 Sep 2025 11:48:40 +0300 Subject: [PATCH] add manual as a default file --- transportmanager/Dockerfile | 1 + .../server/utils/welcome_email.py | 31 +++++++++---------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/transportmanager/Dockerfile b/transportmanager/Dockerfile index 0f818f5..b83f087 100644 --- a/transportmanager/Dockerfile +++ b/transportmanager/Dockerfile @@ -13,6 +13,7 @@ RUN pip install --no-cache-dir -r /app/requirements.txt # App code COPY server /app/server COPY client /app/client +COPY server/assets /app/server/assets # Nginx & Supervisor configs COPY deploy/nginx.conf /etc/nginx/nginx.conf diff --git a/transportmanager/server/utils/welcome_email.py b/transportmanager/server/utils/welcome_email.py index 8d28ff7..5b2d913 100644 --- a/transportmanager/server/utils/welcome_email.py +++ b/transportmanager/server/utils/welcome_email.py @@ -43,20 +43,19 @@ class WelcomeMessage: """ def send_email(self): - # Verify manual existence early and give a clear, actionable error if missing. - if not os.path.isfile(self.manual): - raise FileNotFoundError( - f"Attachment file not found: {self.manual}\n" - f"Tips:\n" - f" - Ensure the file is present in the container image at runtime.\n" - f" - If building with Docker, add: COPY transportmanager/server/assets/ /app/server/assets/\n" - f" - Or set SERVER_ASSETS_DIR to a directory that contains {self.manual_filename}\n" - f" - Current assets folder resolved to: {self.assets_folder}" + # If the manual exists, send with attachment; otherwise, log and send nothing (or integrate a no-attachment sender later). + if os.path.isfile(self.manual): + send_gmail_with_attachment( + to_email=self.email, + subject=self.subject, + body=self.body, + attachment_path=self.manual, ) - - send_gmail_with_attachment( - to_email=self.email, - subject=self.subject, - body=self.body, - attachment_path=self.manual, - ) + else: + logging.warning( + "Welcome manual missing, skipping attachment. Looked at: %s " + "(set SERVER_ASSETS_DIR or WELCOME_MANUAL_FILENAME to adjust)", self.manual + ) + # If you later implement send_gmail() without attachment, call it here. + # from utils.email import send_gmail + # send_gmail(to_email=self.email, subject=self.subject, body=self.body)