add manual as a default file
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user