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)
def _render_email_template_teacher_sub_requests_daily_summary( self, template_content, auth_user_id): """ :param template_content: :param auth_user_id: :return: """ from openstudio.os_class import Class from openstudio.os_teacher import Teacher from openstudio.tools import OsTools from openstudio.os_classes_otcs import ClassesOTCs db = current.db T = current.T os_tools = OsTools() cotcs = ClassesOTCs() teacher = Teacher(auth_user_id) DATE_FORMAT = current.DATE_FORMAT TIME_FORMAT = current.TIME_FORMAT error = False error_msg = '' date_from = current.TODAY_LOCAL + datetime.timedelta(days=1) date_until = date_from + datetime.timedelta(days=45) # G get list of allowed class types query = (db.teachers_classtypes.auth_user_id == auth_user_id) classtype_rows = db(query).select(db.teachers_classtypes.ALL) ct_ids = [] for row in classtype_rows: ct_ids.append(int(row.school_classtypes_id)) open_classes_for_teacher = 0 open_classes = '' description = '' if ct_ids: sys_hostname = os_tools.get_sys_property('sys_hostname') description = XML( template_content.format(teacher_name=teacher.get_first_name(), link_employee_portal=URL( 'ep', 'index', scheme='https', host=sys_hostname))) open_classes = TABLE( THEAD( TR( TH(T("Date"), _align="left"), TH(T("Time"), _align="left"), TH(T("Location"), _align="left"), TH(T("Class"), _align="left"), # TH(), )), _cellspacing="0", _cellpadding='5px', _width='100%', border="0") # Get Open classes in the next 45 days rows = cotcs.get_sub_teacher_rows(date_from, date_until, school_classtypes_ids=ct_ids, only_open=True) for i, row in enumerate(rows): repr_row = list(rows[i:i + 1].render())[0] date = row.classes_otc.ClassDate clsID = row.classes.id cls = Class(clsID, date) regular_teachers = cls.get_regular_teacher_ids() if regular_teachers['auth_teacher_id'] == auth_user_id: continue open_classes.append( TR( TD(repr_row.classes_otc.ClassDate, _align="left"), TD(repr_row.classes.Starttime, _align="left"), TD(repr_row.classes.school_locations_id, _align="left"), TD(repr_row.classes.school_classtypes_id, _align="left"), # TD('Actions here?'), )) open_classes_for_teacher += 1 if not open_classes_for_teacher: error = True error_msg = T( "No upcoming classes with subs required found for this teacher" ) return dict(content=open_classes, description=description, error=error, error_msg=error_msg)