Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions app/logic/emailHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ def __init__(self, formHistoryKey):
self.studentEmail = self.student.STU_EMAIL
self.creatorEmail = self.formHistory.createdBy.email
self.supervisorEmail = self.laborStatusForm.supervisor.EMAIL
self.advisorEmail = self.student.ADVISOR
print ("self.advisorEmail: ", self.advisorEmail)
self.date = self.laborStatusForm.startDate.strftime("%m/%d/%Y")
self.weeklyHours = str(self.laborStatusForm.weeklyHours)
self.contractHours = str(self.laborStatusForm.contractHours)
Expand Down Expand Up @@ -95,7 +97,8 @@ def __init__(self, formHistoryKey):

def send(self, message: Message):
if app.config['ENV'] == 'production' or app.config['ALWAYS_SEND_MAIL']:

print("LOOKING AT MESSAGE")
print(message.html)
# If we have set an override address
if app.config['MAIL_OVERRIDE_ALL']:
message.html = "<b>Original message intended for {}.</b><br>".format(", ".join(message.recipients)) + message.html
Expand Down Expand Up @@ -174,7 +177,8 @@ def laborStatusFormExpired(self):
self.checkRecipient(
studentEmailPurpose=studentTemplate.purpose,
emailPurpose=supervisorTemplate.purpose,
secondaryEmailPurpose=None
secondaryEmailPurpose=None,
advisorEmailPurpose=None
)

def laborStatusFormApproved(self):
Expand Down Expand Up @@ -256,7 +260,8 @@ def LaborOverLoadFormSubmittedNotification(self):
def LaborOverLoadFormApproved(self):
self.checkRecipient("Labor Overload Form Approved For Student",
"Labor Overload Form Approved For Supervisor",
"Labor Overload Form Approved For Financial Aid")
"Labor Overload Form Approved For Financial Aid",
"Labor Overload Form Approved For Academic Advisor")

def LaborOverLoadFormRejected(self):
self.checkRecipient("Labor Overload Form Rejected For Student",
Expand Down Expand Up @@ -321,7 +326,7 @@ def overloadVerification(self, dept, link):
#
# self.send(message)

def checkRecipient(self, studentEmailPurpose=False, emailPurpose=False, secondaryEmailPurpose=False):
def checkRecipient(self, studentEmailPurpose=False, emailPurpose=False, secondaryEmailPurpose=False, advisorEmailPurpose=False):
"""
This method will take in two to three inputs of email purposes. An email to the student is always sent.
The method then checks whether to send the email to only the primary or both the primary and secondary supervisors.
Expand All @@ -344,7 +349,9 @@ def checkRecipient(self, studentEmailPurpose=False, emailPurpose=False, secondar
self.sendEmail(primaryEmail, "Labor Office")
else:
self.sendEmail(primaryEmail, "supervisor")

if advisorEmailPurpose:
advisorEmail = EmailTemplate.get(EmailTemplate.purpose == advisorEmailPurpose)
self.sendEmail(advisorEmail, "Academic Advisor")
# Depending on the parameter 'sendTo', this method will send the email either to the Primary, Secondary, or the Student
def sendEmail(self, template, sendTo):
formTemplate = template.body
Expand Down Expand Up @@ -378,6 +385,10 @@ def sendEmail(self, template, sendTo):
message = Message(template.subject,
recipients=[self.adminEmail])
recipient = 'Admin'
elif sendTo == "Academic Advisor":
message = Message(template.subject,
recipients=[self.advisorEmail])
recipient = 'Academic Advisor'
message.html = formTemplate

newEmailTracker = EmailTracker.create(
Expand All @@ -401,6 +412,7 @@ def replaceText(self, form):
form = form.replace("@@WLS@@", self.laborStatusForm.WLS)
form = form.replace("@@Term@@", self.term.termName)
form = form.replace("@@Admin@@", self.adminName)
form = form.replace("@@Academic Advisor@@", self.advisorEmail)

if self.formHistory.rejectReason:
form = form.replace("@@RejectReason@@", self.formHistory.rejectReason)
Expand Down
4 changes: 2 additions & 2 deletions app/models/emailTemplate.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ class EmailTemplate (baseModel):
#Emails in labor status form:
#LSF
#1:When labor status form is submitted: send to student
#2:When LSF is approved: send to supervisor and student
#2:When LSF is approved: send to supervisor and student and academic advisor
#3:When LSF is rejected: send to supervisor and student
#4:When LSF is adjusted: send to supervisor and student (?)
#Pending
#5:When a pending form is modified: send to supervisor and student
#LRF
#6:When labor release form is submitted: Send to student
#7:When lrf is approved: send to supervisor and student
#7:When lrf is approved: send to supervisor and student and academic advisor
#8:When lrf is rejected: send to supervisor and student
#Overload
#9: When labor overload form submitted (by student): send to supervisor(??? and advisor???)
Expand Down
10 changes: 10 additions & 0 deletions database/base_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,16 @@
"audience":"Supervisor"
},
{
"purpose":"Labor Overload Form Approved For Academic Advisor",
"formType":"Labor Overload Form",
"action":"Approved",
"subject":"Labor Overload Form Approved",
"body":'''
<p> An overload for <strong>@@Student@@</strong>, <strong>@@StudB@@</strong> has been approved. </p>
''',
"audience":"Academic Advisor"
},
{
"purpose":"Labor Overload Form Rejected For Student",
"formType":"Labor Overload Form",
"action":"Rejected",
Expand Down
2 changes: 1 addition & 1 deletion database/demo_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@
FormHistory.insert([{
"formHistoryID": 2,
"formID_id": "2",
"historyType_id": "Labor Status Form",
"historyType_id": "Labor Overload Form",
"createdBy_id": 1,
"createdDate": f"{current_year}-04-14",
"status_id": "Pending"
Expand Down