Harshit Pathak 3 hónapja
szülő
commit
fcc17b0ad2

BIN
core/__pycache__/urls.cpython-313.pyc


BIN
core/__pycache__/views.cpython-313.pyc


+ 6 - 0
core/scripts/mailbody.txt

@@ -0,0 +1,6 @@
+Hello Manager,
+
+Please find the ETS Competitor Intelligence report for October 28, 2025.
+
+Best regards,
+Automation System

+ 6 - 1
core/urls.py

@@ -21,6 +21,9 @@ from core.views import (
     ContentRulesView,
     ContentRulesView,
     ExcelUploadView,
     ExcelUploadView,
 )
 )
+from .views import open_outlook_mail
+
+
 
 
 urlpatterns = [
 urlpatterns = [
     # Single product scoring
     # Single product scoring
@@ -32,5 +35,7 @@ urlpatterns = [
     
     
     path('api/content-rules/', ContentRulesView.as_view(), name='content_rules'),
     path('api/content-rules/', ContentRulesView.as_view(), name='content_rules'),
     
     
-    path('api/upload-rules/', ExcelUploadView.as_view(), name='upload_rules')
+    path('api/upload-rules/', ExcelUploadView.as_view(), name='upload_rules'),
+
+    path('run-script/', open_outlook_mail, name='open_outlook_mail'),
 ]
 ]

+ 40 - 2
core/views.py

@@ -1,7 +1,7 @@
 
 
 # views.py (FULLY FIXED with comprehensive logging)
 # views.py (FULLY FIXED with comprehensive logging)
 from django.shortcuts import render, get_object_or_404
 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.views import View
 from django.core.cache import cache
 from django.core.cache import cache
 from django.db.models import Q
 from django.db.models import Q
@@ -936,4 +936,42 @@ class ExcelUploadView(APIView):
                     try:
                     try:
                         os.remove(tmp_path)
                         os.remove(tmp_path)
                     except Exception:
                     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)