add manual as a default file

This commit is contained in:
2025-09-10 11:48:40 +03:00
parent 79317482aa
commit 8b06e580fe
2 changed files with 16 additions and 16 deletions

View File

@@ -13,6 +13,7 @@ RUN pip install --no-cache-dir -r /app/requirements.txt
# App code # App code
COPY server /app/server COPY server /app/server
COPY client /app/client COPY client /app/client
COPY server/assets /app/server/assets
# Nginx & Supervisor configs # Nginx & Supervisor configs
COPY deploy/nginx.conf /etc/nginx/nginx.conf COPY deploy/nginx.conf /etc/nginx/nginx.conf

View File

@@ -43,20 +43,19 @@ class WelcomeMessage:
""" """
def send_email(self): def send_email(self):
# Verify manual existence early and give a clear, actionable error if missing. # If the manual exists, send with attachment; otherwise, log and send nothing (or integrate a no-attachment sender later).
if not os.path.isfile(self.manual): if os.path.isfile(self.manual):
raise FileNotFoundError( send_gmail_with_attachment(
f"Attachment file not found: {self.manual}\n" to_email=self.email,
f"Tips:\n" subject=self.subject,
f" - Ensure the file is present in the container image at runtime.\n" body=self.body,
f" - If building with Docker, add: COPY transportmanager/server/assets/ /app/server/assets/\n" attachment_path=self.manual,
f" - Or set SERVER_ASSETS_DIR to a directory that contains {self.manual_filename}\n"
f" - Current assets folder resolved to: {self.assets_folder}"
) )
else:
send_gmail_with_attachment( logging.warning(
to_email=self.email, "Welcome manual missing, skipping attachment. Looked at: %s "
subject=self.subject, "(set SERVER_ASSETS_DIR or WELCOME_MANUAL_FILENAME to adjust)", self.manual
body=self.body, )
attachment_path=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)