|
|
@@ -1,7 +1,7 @@
|
|
|
|
|
|
# views.py (FULLY FIXED with comprehensive logging)
|
|
|
from django.shortcuts import render, get_object_or_404
|
|
|
-from django.http import JsonResponse
|
|
|
+from django.http import HttpResponse, JsonResponse
|
|
|
from django.views import View
|
|
|
from django.core.cache import cache
|
|
|
from django.db.models import Q
|
|
|
@@ -936,4 +936,42 @@ class ExcelUploadView(APIView):
|
|
|
try:
|
|
|
os.remove(tmp_path)
|
|
|
except Exception:
|
|
|
- pass # give up silently; OS will clean temp files later
|
|
|
+ pass # give up silently; OS will clean temp files later
|
|
|
+
|
|
|
+
|
|
|
+import os
|
|
|
+import urllib.parse
|
|
|
+from django.http import HttpResponse
|
|
|
+from django.conf import settings
|
|
|
+
|
|
|
+def open_outlook_mail(request):
|
|
|
+ try:
|
|
|
+ body_path = os.path.join(settings.BASE_DIR, 'core', 'scripts', 'mailbody.txt')
|
|
|
+ with open(body_path, 'r', encoding='utf-8') as f:
|
|
|
+ body = f.read().strip()
|
|
|
+
|
|
|
+ subject = "ETS Competitor Intelligence - October 28, 2025"
|
|
|
+ recipient = "manager@example.com"
|
|
|
+
|
|
|
+ encoded_subject = urllib.parse.quote(subject)
|
|
|
+ encoded_body = urllib.parse.quote(body)
|
|
|
+ mailto_url = f"mailto:{recipient}?subject={encoded_subject}&body={encoded_body}"
|
|
|
+
|
|
|
+ html = f"""
|
|
|
+ <html>
|
|
|
+ <head><title>Opening Outlook...</title></head>
|
|
|
+ <body style="font-family: Arial, sans-serif; text-align: center; margin-top: 80px;">
|
|
|
+ <script>
|
|
|
+ window.onload = function() {{
|
|
|
+ window.location.href = "{mailto_url}";
|
|
|
+ }};
|
|
|
+ </script>
|
|
|
+ <h2>📧 Opening Outlook...</h2>
|
|
|
+ <p>If Outlook does not open automatically, <a href="{mailto_url}">click here</a>.</p>
|
|
|
+ </body>
|
|
|
+ </html>
|
|
|
+ """
|
|
|
+ return HttpResponse(html)
|
|
|
+
|
|
|
+ except Exception as e:
|
|
|
+ return HttpResponse(f"<h3>Error:</h3><p>{str(e)}</p>", status=500)
|