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
17 changes: 8 additions & 9 deletions app/logic/emailHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,11 +347,11 @@ def checkRecipient(self, studentEmailPurpose=False, emailPurpose=False, secondar

# 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
formTemplate = self.replaceText(formTemplate)
if sendTo == "student":
message = Message(template.subject,
recipients=[self.studentEmail])
message = Message(template.subject, recipients = [self.studentEmail])
recipient = 'Student'
elif sendTo == "secondary":
if self.term.isBreak:
Expand All @@ -363,8 +363,7 @@ def sendEmail(self, template, sendTo):
recipients=supervisorEmails)
recipient = 'Secondary Supervisor'
else:
message = Message(template.subject,
recipients=[self.supervisorEmail, self.primaryEmail])
message = Message(template.subject, recipients=[self.supervisorEmail, self.primaryEmail])
recipient = 'Primary Supervisor'
elif sendTo == "Labor Office":
message = Message(template.subject,
Expand All @@ -375,18 +374,18 @@ def sendEmail(self, template, sendTo):
recipients=[self.supervisorEmail])
recipient = 'Primary Supervisor'
elif sendTo == "admin":
message = Message(template.subject,
recipients=[self.adminEmail])
message = Message(template.subject, recipients=[self.adminEmail])
recipient = 'Admin'
message.html = formTemplate

newEmailTracker = EmailTracker.create(
formID = self.laborStatusForm.laborStatusFormID,
date = datetime.today().strftime('%Y-%m-%d'),
recipient = recipient,
subject = template.subject
template = template.emailTemplateID,
recipientEmails = ",".join(message.recipients),
body = formTemplate,
)

self.send(message)

# This method is responsible for replacing the keyword form the templates in the database with the data in the laborStatusForm
Expand Down
9 changes: 7 additions & 2 deletions app/models/emailTracker.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
from app.models import *
from app.models.laborStatusForm import LaborStatusForm
from app.models.emailTemplate import EmailTemplate

class EmailTracker(baseModel):
emailTrackerID = PrimaryKeyField()
formID = ForeignKeyField(LaborStatusForm, on_delete="cascade") # foreign key to lsf
formID = ForeignKeyField(LaborStatusForm) # foreign key to lsf
date = DateField()
recipient = CharField()
subject = CharField()
template = ForeignKeyField(EmailTemplate) # foreign key to email template
recipientEmails = TextField()
body = TextField()


4 changes: 4 additions & 0 deletions database/data-scrub.sql
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,7 @@ UPDATE laborstatusform set laborDepartmentNotes=CASE WHEN LENGTH(laborDepartment
UPDATE notes set notesContents='Notes are not visible except in the production environment'

UPDATE studentlaborevaluation SET attendance_comment=CASE WHEN LENGTH(attendance_comment)>0 THEN '<redacted>' ELSE '' END, accountability_comment=CASE WHEN LENGTH(accountability_comment)>0 THEN '<redacted>' ELSE '' END, teamwork_comment=CASE WHEN LENGTH(teamwork_comment)>0 THEN '<redacted>' ELSE '' END, initiative_comment=CASE WHEN LENGTH(initiative_comment)>0 THEN '<redacted>' ELSE '' END, respect_comment=CASE WHEN LENGTH(respect_comment)>0 THEN '<redacted>' ELSE '' END, learning_comment=CASE WHEN LENGTH(learning_comment)>0 THEN '<redacted>' ELSE '' END, jobSpecific_comment=CASE WHEN LENGTH(jobSpecific_comment)>0 THEN '<redacted>' ELSE '' END, transcript_comment=CASE WHEN LENGTH(transcript_comment)>0 THEN '<redacted>' ELSE '' END

-- removes parts of the email tracker
UPDATE emailtracker set recipientEmails=CASE WHEN LENGTH(recipientEmails)>0 THEN '<redacted>' ELSE '' END
UPDATE emailtracker set body=CASE WHEN LENGTH(body)>0 THEN '<redacted>' ELSE '' END
15 changes: 15 additions & 0 deletions database/demo_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from app.models.laborStatusForm import LaborStatusForm
from app.models.formHistory import FormHistory
from app.models.notes import Notes
from app.models.emailTracker import EmailTracker

print("Inserting data for demo and testing purposes")

Expand Down Expand Up @@ -609,3 +610,17 @@
]
Notes.insert_many(notes).on_conflict_replace().execute()
print(" * laborOfficeNotes added")


#############################
# Creates an emailTracker
#############################
EmailTracker.insert([{
"emailTrackerID": 1000000,
"formID": 2,
"date": "2026-06-18",
"recipient": "Julius Fritz",
"template": 4,
"recipientEmails": "fritzj2@berea.edu",
"body": "super secret text that you cant read"
Comment thread
MImran2002 marked this conversation as resolved.
}]).on_conflict_replace().execute()