Пример #1
0
def notify_child_assignments():
    families = Family.objects.all()

    with Mailer() as mail:
        for family in families:
            parents = family.parents.all()
            children = family.children.filter(emailed=False).all()

            if children.count() > 0:
                for child in children:
                    position = "parents"
                    message = ASSIGNED_TO_FAMILY.format(
                        position, DOMAIN_URL, child.magic_id)
                    mail.send_email(
                        Message(child, "Mums and Dads Parent Assignment",
                                message))
                    child.emailed = True
                    child.save()

                for parent in parents:
                    position = "children"
                    message = ASSIGNED_TO_FAMILY.format(
                        position, DOMAIN_URL, parent.magic_id)
                    mail.send_email(
                        Message(parent, "Mums and Dads Child Assignment",
                                message))
Пример #2
0
def email_inactive_accounts():
    students = Student.objects.filter(activated=False).all()

    with Mailer() as mail:
        for student in students:
            message = INACTIVE_ACCOUNT_TEMPLATE % (DOMAIN_URL, student.magic_id)
            mail.send_email(Message(student, "Mums and Dads Account Activation", message))
Пример #3
0
    def get_new_student_popup(self):
        popup = GET_NEW_STUDENT_POPUP.format(self.username)
        message = GET_NEW_STUDENT_EMAIL.format(DOMAIN_URL, self.magic_id)

        with Mailer() as mail:
            mail.send_email(Message(self, "Mums and Dads login link", message))

        return {'message': popup, 'state': 'success'}
Пример #4
0
def notify_family_assignments():
    families = Family.objects.all()

    with Mailer() as mail:
        for family in families:
            parents = family.parents.filter(partner__isnull=False, confirmed=True, emailed=False).all()

            for parent in parents:
                partner = parent.partner
                message = ASSIGNED_PARTNER_TEMPLATE % (partner, partner.username)
                mail.send_email(Message(parent, "Mums and Dads Partner Assignment", message))
                partner.emailed = True
                partner.save()
Пример #5
0
 def test_can_disable_sending_emails_for_testing(self):
     with Mailer(False) as mailer:
         # If true it would crash here
         mailer.send_email(None)
     self.assertTrue(True)