| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- import logging
- # Configure logging
- logging.basicConfig(level=logging.INFO)
- logger = logging.getLogger("notifications")
- EMAIL_TEMPLATES = {
- "en": {
- "status_change_subject": "Radionica3D: Update on your Order #{order_id}",
- "status_change_body": "Hello {first_name},\n\nYour order status has been updated to: {new_status}.\n\nCheck details here: http://localhost:5173/orders"
- },
- "ru": {
- "status_change_subject": "Radionica3D: Обновление по вашему заказу #{order_id}",
- "status_change_body": "Здравствуйте, {first_name},\n\nСтатус вашего заказа обновлен на: {new_status}.\n\nПодробности по ссылке: http://localhost:5173/orders"
- },
- "me": {
- "status_change_subject": "Radionica3D: Ažuriranje vaše narudžbe #{order_id}",
- "status_change_body": "Zdravo {first_name},\n\nStatus vaše narudžbe je ažuriran na: {new_status}.\n\nDetalje provjerite ovdje: http://localhost:5173/orders"
- },
- "ua": {
- "status_change_subject": "Radionica3D: Оновлення вашого замовлення #{order_id}",
- "status_change_body": "Вітаємо, {first_name},\n\nСтатус вашого замовлення оновлено на: {new_status}.\n\nДеталі за посиланням: http://localhost:5173/orders"
- }
- }
- def send_email(to_email: str, subject: str, body: str):
- """
- Mock function for sending emails. Users will configure SMTP here.
- """
- pass
- def notify_status_change(email: str, order_id: int, new_status: str, first_name: str, lang: str = "en"):
- """
- Hook to send notification when order status changes.
- The USER will configure SMTP here later.
- """
- logger.info(f"NOTIFICATION HOOK: Sending status update to {email} for Order #{order_id}. New Status: {new_status} (Lang: {lang})")
-
- lang = lang.lower() if lang else "en"
- if lang not in EMAIL_TEMPLATES:
- lang = "en"
-
- templates = EMAIL_TEMPLATES[lang]
- subject = templates["status_change_subject"].format(order_id=order_id)
- body = templates["status_change_body"].format(
- first_name=first_name,
- new_status=new_status
- )
-
- # send_email(email, subject, body)
-
- return True
|