Пример #1
0
 def send_mail_failed(cuID):
     """
         When a recurring payment fails, mail customer with request to pay manually
     """
     os_mail = OsMail()
     msgID = os_mail.render_email_template('payment_recurring_failed')
     os_mail.send(msgID, cuID)
Пример #2
0
    def email_trailcard_follow_up(self):
        """
        Send teachers reminders when a sub for their class hasn't been found yet.
        :return:
        """
        from openstudio.os_mail import OsMail

        T = current.T
        db = current.db
        os_mail = OsMail()
        TODAY_LOCAL = current.TODAY_LOCAL
        yesterday = TODAY_LOCAL - datetime.timedelta(days=1)

        left = [
            db.school_classcards.on(
                db.customers_classcards.school_classcards_id ==
                db.school_classcards.id),
            db.auth_user.on(
                db.customers_classcards.auth_customer_id == db.auth_user.id)
        ]

        query = (db.school_classcards.Trialcard == True) & \
                (db.customers_classcards.Enddate == yesterday)

        rows = db(query).select(db.customers_classcards.ALL,
                                db.auth_user.display_name,
                                left=left)

        mails_sent = 0

        for row in rows:
            result = os_mail.render_email_template(
                'trial_follow_up',
                customers_classcards_id=row.customers_classcards.id,
                return_html=True)

            os_mail.send(
                message_html=result['html_message'],
                message_subject=result['msg_subject'],
                auth_user_id=row.customers_classcards.auth_customer_id)

            mails_sent += 1

        return "Sent trial card follow up mails: %s" % mails_sent
Пример #3
0
    def email_reminders_teachers_sub_request_open(self):
        """
        Send teachers reminders when a sub for their class hasn't been found yet.
        :return:
        """
        from openstudio.os_class import Class
        from openstudio.os_mail import OsMail
        from openstudio.os_sys_email_reminders import SysEmailReminders

        T = current.T
        db = current.db
        TODAY_LOCAL = current.TODAY_LOCAL

        # Check if reminders configured
        sys_reminders = SysEmailReminders('teachers_sub_request_open')
        reminders = sys_reminders.list()

        mails_sent = 0
        for reminder in reminders:
            # Get list of open classes on reminder date
            reminder_date = TODAY_LOCAL + datetime.timedelta(reminder.Days)

            query = (db.classes_otc.Status == 'open') & \
                    (db.classes_otc.ClassDate == reminder_date)

            rows = db(query).select(db.classes_otc.ALL)
            for row in rows:
                clsID = row.classes_id
                cls = Class(clsID, row.ClassDate)
                regular_teachers = cls.get_regular_teacher_ids()

                if not regular_teachers['error']:
                    auth_teacher_id = regular_teachers['auth_teacher_id']
                    teacher = db.auth_user(auth_teacher_id)

                    os_mail = OsMail()
                    result = os_mail.render_email_template(
                        'teacher_sub_request_open_reminder',
                        classes_otc_id=row.id,
                        return_html=True)

                    send_result = False
                    if not result['error']:
                        send_result = os_mail.send(
                            message_html=result['html_message'],
                            message_subject=T("Reminder - open class"),
                            auth_user_id=auth_teacher_id)

                    if send_result:
                        mails_sent += 1

            # send reminder to teacher

        return "Sent mails: %s" % mails_sent
Пример #4
0
def webhook_invoice_chargeback(iID, chargeback_amount, chargeback_date,
                               mollie_payment_id, chargeback_id,
                               chargeback_details):
    """
    Chargebacks happen when a direct debit payment fails due to insufficient funds in the customers' bank account
    :return:
    """
    invoice = Invoice(iID)

    ipID = invoice.payment_add(
        chargeback_amount,
        chargeback_date,
        payment_methods_id=100,  # Static id for Mollie payments
        mollie_payment_id=mollie_payment_id,
        note="Mollie Chargeback (%s) - %s" %
        (chargeback_id, chargeback_details))

    # Notify customer of chargeback
    cuID = invoice.get_linked_customer_id()
    os_mail = OsMail()
    msgID = os_mail.render_email_template('payment_recurring_failed')
    os_mail.send(msgID, cuID)
Пример #5
0
    def email_teachers_sub_requests_daily_summary(self):
        """
        Send a daily summary of open sub requests to each teacher for the classtypes
        they're allowed to teach
        :return:
        """
        from .os_mail import OsMail
        from .os_teachers import Teachers

        db = current.db
        T = current.T
        os_mail = OsMail()

        # Get list of teachers
        teachers = Teachers()
        teacher_id_rows = teachers.get_teacher_ids()

        mails_sent = 0
        for row in teacher_id_rows:
            os_mail = OsMail()
            result = os_mail.render_email_template(
                'teacher_sub_requests_daily_summary',
                auth_user_id=row.id,
                return_html=True)

            send_result = False
            if not result['error']:
                send_result = os_mail.send(
                    message_html=result['html_message'],
                    message_subject=T("Daily summary - open classes"),
                    auth_user_id=row.id)

            if send_result:
                mails_sent += 1

        return "Sent mails: %s" % mails_sent