Add
Browse files- Scheduler.py +90 -47
- app.py +6 -4
Scheduler.py
CHANGED
|
@@ -1,9 +1,11 @@
|
|
| 1 |
import pandas as pd
|
| 2 |
-
import smtplib
|
| 3 |
-
import ssl
|
| 4 |
import os
|
| 5 |
-
from email.mime.text import MIMEText
|
| 6 |
-
from email.mime.multipart import MIMEMultipart
|
|
|
|
|
|
|
| 7 |
from dotenv import load_dotenv
|
| 8 |
from datetime import datetime, timedelta
|
| 9 |
|
|
@@ -12,10 +14,12 @@ load_dotenv()
|
|
| 12 |
|
| 13 |
class Schedule:
|
| 14 |
def __init__(self):
|
| 15 |
-
|
| 16 |
-
self.
|
| 17 |
-
self.
|
| 18 |
-
self.
|
|
|
|
|
|
|
| 19 |
|
| 20 |
def defaults(self,start_date,start_time,slot_length):
|
| 21 |
self.date = start_date
|
|
@@ -42,44 +46,83 @@ class Schedule:
|
|
| 42 |
self.df["Slot"] = slots
|
| 43 |
|
| 44 |
|
|
|
|
| 45 |
def send_emails(self):
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 85 |
|
|
|
|
| 1 |
import pandas as pd
|
| 2 |
+
# import smtplib
|
| 3 |
+
# import ssl
|
| 4 |
import os
|
| 5 |
+
# from email.mime.text import MIMEText
|
| 6 |
+
# from email.mime.multipart import MIMEMultipart
|
| 7 |
+
# from sendgrid import SendGridAPIClient
|
| 8 |
+
# from sendgrid.helpers.mail import Mail
|
| 9 |
from dotenv import load_dotenv
|
| 10 |
from datetime import datetime, timedelta
|
| 11 |
|
|
|
|
| 14 |
|
| 15 |
class Schedule:
|
| 16 |
def __init__(self):
|
| 17 |
+
# Email server configuration commented out
|
| 18 |
+
# self.server = "smtp.gmail.com"
|
| 19 |
+
# self.port = 587
|
| 20 |
+
# self.sender = "axionai101@gmail.com"
|
| 21 |
+
# self.password = os.getenv("app_password")
|
| 22 |
+
pass
|
| 23 |
|
| 24 |
def defaults(self,start_date,start_time,slot_length):
|
| 25 |
self.date = start_date
|
|
|
|
| 46 |
self.df["Slot"] = slots
|
| 47 |
|
| 48 |
|
| 49 |
+
# Function to send interview emails - COMMENTED OUT
|
| 50 |
def send_emails(self):
|
| 51 |
+
# Email sending functionality disabled
|
| 52 |
+
print(f"Email sending disabled. Would have sent {len(self.df)} interview invitations.")
|
| 53 |
+
return True # Return success for compatibility
|
| 54 |
+
|
| 55 |
+
# Original email sending code commented out:
|
| 56 |
+
# SENDGRID_API_KEY = os.getenv("SendGrid_Secret")
|
| 57 |
+
# SENDER_EMAIL = os.getenv("EMAIL") # Verified sender email in SendGrid
|
| 58 |
+
|
| 59 |
+
# if not SENDGRID_API_KEY or not SENDER_EMAIL:
|
| 60 |
+
# logging.error("SendGrid API key or sender email not set in environment variables.")
|
| 61 |
+
# return
|
| 62 |
+
|
| 63 |
+
# sg_client = SendGridAPIClient(SENDGRID_API_KEY)
|
| 64 |
+
# print("Starting SendGrid email sending")
|
| 65 |
+
|
| 66 |
+
# for _, row in candidates.iterrows():
|
| 67 |
+
# recipient_email = row['Email']
|
| 68 |
+
# name = row['Name']
|
| 69 |
+
# interview_date = row["alloted"][:10].strip()
|
| 70 |
+
# interview_time = row["alloted"][10:].strip()
|
| 71 |
+
|
| 72 |
+
# unique_id = datetime.now().strftime("%Y%m%d%H%M%S")
|
| 73 |
+
# subject = f"Your Interview at WeHack is Scheduled 🚀 [Ref: {unique_id}]"
|
| 74 |
+
|
| 75 |
+
# # Customize the email HTML content as needed
|
| 76 |
+
# body = f"""
|
| 77 |
+
# <html>
|
| 78 |
+
# <body>
|
| 79 |
+
# <p>Dear {name},</p>
|
| 80 |
+
|
| 81 |
+
# <p>We are pleased to inform you that, following a review of your application,
|
| 82 |
+
# you have been selected to proceed to the next stage of the hiring process at <b>WeHack</b>.</p>
|
| 83 |
+
|
| 84 |
+
# <p><b>Date:</b> {interview_date}<br>
|
| 85 |
+
# <b>Time:</b> {interview_time}<br>
|
| 86 |
+
# <b>Mode:</b> Will be contacted further</p>
|
| 87 |
+
|
| 88 |
+
# <p>This interview presents an excellent opportunity for us to further explore your qualifications,
|
| 89 |
+
# experiences, and interest in the position. We are eager to learn more about you and how you envision contributing to our team.</p>
|
| 90 |
+
|
| 91 |
+
# <p>Please ensure your availability at the scheduled time. Should you have any questions, need to reschedule,
|
| 92 |
+
# or require assistance, do not hesitate to contact us.</p>
|
| 93 |
+
|
| 94 |
+
# <p>We look forward to our conversation and appreciate your continued interest in joining <b>WeHack</b>.</p>
|
| 95 |
+
|
| 96 |
+
# <p> </p> <!-- Invisible space to prevent auto-quoting -->
|
| 97 |
+
|
| 98 |
+
# <p>Kind regards,<br>
|
| 99 |
+
# HR<br>
|
| 100 |
+
# WeHack Organization<br>
|
| 101 |
+
# [Contact Information]</p>
|
| 102 |
+
# </body>
|
| 103 |
+
# </html>
|
| 104 |
+
# """
|
| 105 |
+
|
| 106 |
+
|
| 107 |
+
# message = Mail(
|
| 108 |
+
# from_email=SENDER_EMAIL,
|
| 109 |
+
# to_emails=recipient_email,
|
| 110 |
+
# subject=subject,
|
| 111 |
+
# html_content=body
|
| 112 |
+
# )
|
| 113 |
+
|
| 114 |
+
# try:
|
| 115 |
+
# response = sg_client.send(message)
|
| 116 |
+
# if 200 <= response.status_code < 300:
|
| 117 |
+
# print(f"✅ Email sent to {name} ({recipient_email})")
|
| 118 |
+
# # Add event to calendar only after successful email
|
| 119 |
+
# add_event_to_calendar(name, recipient_email, interview_date, interview_time, slot)
|
| 120 |
+
# else:
|
| 121 |
+
# logging.error(f"Failed to send email to {recipient_email}, status code: {response.status_code}")
|
| 122 |
+
# except Exception as e:
|
| 123 |
+
# logging.error(f"Exception while sending email to {recipient_email}: {e}")
|
| 124 |
+
|
| 125 |
+
# time.sleep(2) # avoid rate limiting
|
| 126 |
+
|
| 127 |
+
# print("✅ All emails have been sent successfully!")
|
| 128 |
|
app.py
CHANGED
|
@@ -615,12 +615,14 @@ def email():
|
|
| 615 |
# Create user records in database
|
| 616 |
create_user(scheduler)
|
| 617 |
|
| 618 |
-
#
|
| 619 |
-
scheduler.send_emails()
|
|
|
|
| 620 |
|
| 621 |
return jsonify({
|
| 622 |
-
"output": "
|
| 623 |
-
"scheduled_count": len(scheduler.df)
|
|
|
|
| 624 |
})
|
| 625 |
|
| 626 |
except FileNotFoundError as e:
|
|
|
|
| 615 |
# Create user records in database
|
| 616 |
create_user(scheduler)
|
| 617 |
|
| 618 |
+
# Email sending disabled - just log what would have been sent
|
| 619 |
+
# scheduler.send_emails()
|
| 620 |
+
logging.info(f"Email sending disabled. Would have sent invitations to {len(scheduler.df)} candidates.")
|
| 621 |
|
| 622 |
return jsonify({
|
| 623 |
+
"output": "Interview slots scheduled successfully (email sending disabled)",
|
| 624 |
+
"scheduled_count": len(scheduler.df),
|
| 625 |
+
"note": "Candidates have been scheduled but no emails were sent"
|
| 626 |
})
|
| 627 |
|
| 628 |
except FileNotFoundError as e:
|