Exemplo n.º 1
0
    def _render_email_template_teacher_sub_request_open_reminder(
            self, template_content, cotcID):
        """
        Render mail template for teacher no sub found yet reminders
        :param cotcID: db.classes_otc.id
        :return: html - mail body for reminder
        """
        from openstudio.os_class import Class

        T = current.T
        db = current.db
        DATE_FORMAT = current.DATE_FORMAT
        TIME_FORMAT = current.TIME_FORMAT

        error = False
        error_msg = ''

        cotc = db.classes_otc(cotcID)

        cls = Class(cotc.classes_id, cotc.ClassDate)
        regular_teachers = cls.get_regular_teacher_ids()
        teacher_name = ''
        if not regular_teachers['error']:
            auth_teacher_id = regular_teachers['auth_teacher_id']
            teacher = db.auth_user(auth_teacher_id)
            teacher_name = teacher.first_name

        class_info = TABLE(TR(
            TH(T('Date'), _align="right"),
            TD(cotc.ClassDate.strftime(DATE_FORMAT), _align="left")),
                           TR(
                               TH(T('Time'), _align="right"),
                               TD(cls.cls.Starttime.strftime(TIME_FORMAT),
                                  ' - ',
                                  cls.cls.Endtime.strftime(TIME_FORMAT),
                                  _align="left")),
                           TR(TH(T('Location'), _align="right"),
                              TD(cls.get_location_name(), _align="left")),
                           TR(TH(T('Class'), _align="right"),
                              TD(cls.get_classtype_name(), _align="left")),
                           _cellspacing="0",
                           _cellpadding='5px',
                           _width='100%',
                           border="0")

        description = class_info
        content = XML(template_content.format(teacher_name=teacher_name, ))

        return dict(error=error,
                    error_msg=error_msg,
                    content=content,
                    description=description)
Exemplo n.º 2
0
    def _render_email_class_info_mail(self, clattID):
        """
        :param template_content: Mail content
        :param workshops_products_id: db.workshops_products.id
        :return: mail body for workshop
        """
        from .os_class_attendance import ClassAttendance
        from .os_class import Class
        from .os_customer import Customer

        db = current.db
        T = current.T
        DATE_FORMAT = current.DATE_FORMAT
        TIME_FORMAT = current.TIME_FORMAT
        clatt = ClassAttendance(clattID)
        clsID = clatt.row.classes_id
        date = clatt.row.ClassDate
        cls = Class(clsID, date)
        customer = Customer(clatt.row.auth_customer_id)

        description = TABLE(TR(TH(T('Date')),
                               TD(clatt.row.ClassDate.strftime(DATE_FORMAT), _align="left")),
                            TR(TH(T('Time')),
                               TD(cls.get_starttime(), _aligh="left")),
                            TR(TH(T('Class')),
                               TD(cls.get_classtype_name(), _aligh="left")),
                            TR(TH(T('Location')),
                               TD(cls.get_location_name(), _aligh="left")),
                            _cellspacing="0", _cellpadding='5px', _width='100%', border="0")

        content = ''
        class_otc_mail = db.classes_otc_mail(classes_id=clsID, ClassDate=date)
        class_mail = db.classes_mail(classes_id=clsID)
        if class_otc_mail:
            content = class_otc_mail.MailContent or ""
        elif class_mail:
            content = class_mail.MailContent or ""

        return dict(
            content=DIV(
                XML(content.format(
                    customer_first_name = customer.row.first_name
                ))
            ),
            description=description
        )
Exemplo n.º 3
0
    def _render_email_template_teacher_sub_offer(self, template_content,
                                                 classes_otc_sub_avail_id):
        """

        :param classes_otc_sub_avail_id:
        :return: mail body for declined class sub request
        """
        from openstudio.os_class import Class
        from openstudio.os_teacher import Teacher

        db = current.db
        T = current.T
        DATE_FORMAT = current.DATE_FORMAT
        TIME_FORMAT = current.TIME_FORMAT

        cotcsa = db.classes_otc_sub_avail(classes_otc_sub_avail_id)
        teacher = Teacher(cotcsa.auth_teacher_id)
        cotc = db.classes_otc(cotcsa.classes_otc_id)
        cls = Class(cotc.classes_id, cotc.ClassDate)

        class_info = TABLE(TR(
            TH(T('Date'), _align="right"),
            TD(cotc.ClassDate.strftime(DATE_FORMAT), _align="left")),
                           TR(
                               TH(T('Time'), _align="right"),
                               TD(cls.cls.Starttime.strftime(TIME_FORMAT),
                                  ' - ',
                                  cls.cls.Endtime.strftime(TIME_FORMAT),
                                  _align="left")),
                           TR(TH(T('Location'), _align="right"),
                              TD(cls.get_location_name(), _align="left")),
                           TR(TH(T('Class'), _align="right"),
                              TD(cls.get_classtype_name(), _align="left")),
                           _cellspacing="0",
                           _cellpadding='5px',
                           _width='100%',
                           border="0")

        content = XML(
            template_content.format(teacher_name=teacher.get_first_name()))

        return dict(content=content, description=class_info)