Example #1
0
    def email_intervention(self):
        subject = render_to_string(
            'notifications/email/intervention_alert_subject.txt',
            {'intervention': self})
        message = render_to_string(
            'notifications/email/intervention_alert_message.html',
            {'intervention': self, 'reasons': self.reasons.split(',')})
        # Send referral to settings.INTERVENTIONS_EMAIL
        email_user(settings.SERVER_EMAIL,
                   settings.INTERVENTIONS_EMAIL,
                   self.instructor.email,
                   subject,
                   message)

        # Notify students that an intervention referral was submitted for them
        subject = render_to_string(
            'notifications/email/intervention_student_subject.txt',
            {'intervention': self})
        for student in self.students.all():
            if student.email:
                message = render_to_string(
                    'notifications/email/intervention_student_message.html',
                    {'student': student})
                email_user(settings.SERVER_EMAIL,
                           student.email,
                           None,
                           subject,
                           message)
Example #2
0
 def email_contact(self):
     # Send students the instructor's message
     for student in self.students.all():
         if student.email:
             message = linebreaks(self.message)
             email_user(self.instructor.email,
                        student.email,
                        None,
                        self.subject,
                        message)