def payment_fixed_rate(): """ Configure fixed rate payments for this teacher """ from openstudio.os_customer import Customer from openstudio.os_teacher import Teacher teID = request.vars['teID'] response.view = 'general/only_content.html' customer = Customer(teID) response.title = customer.get_name() response.subtitle = T("Payments") teacher = Teacher(teID) content = DIV( teacher.get_payment_fixed_rate_default_display(), teacher.get_payment_fixed_rate_classes_display() ) back = back_index() return dict(content=content, #menu=menu, back=back)
def payment_travel(): """ Configure travel allowance for teachers """ from openstudio.os_customer import Customer from openstudio.os_teacher import Teacher teID = request.vars['teID'] response.view = 'general/only_content.html' customer = Customer(teID) response.title = customer.get_name() response.subtitle = T("Travel allowance") teacher = Teacher(teID) content = teacher.get_payment_travel_display() add = os_gui.get_button('add', URL('teachers', 'payment_travel_add', vars={'teID': teID}), _class='pull-right') back = back_index() return dict(content=content, header_tools=add, back=back)
def payment_fixed_rate_default(): """ Add default fixed rate for this teacher """ from openstudio.os_customer import Customer from openstudio.os_teacher import Teacher from openstudio.os_forms import OsForms teID = request.vars['teID'] response.view = 'general/only_content.html' customer = Customer(teID) response.title = customer.get_name() response.subtitle = T("Teacher profile") os_forms = OsForms() return_url = payment_fixed_rate_default_return_url(teID) db.teachers_payment_fixed_rate_default.auth_teacher_id.default = teID teacher = Teacher(teID) default_payments = teacher.get_payment_fixed_rate_default() if default_payments: title = H4(T('Edit default rate')) result = os_forms.get_crud_form_update( db.teachers_payment_fixed_rate_default, return_url, default_payments.first().id ) else: title = H4(T('Add default rate')) result = os_forms.get_crud_form_create( db.teachers_payment_fixed_rate_default, return_url, ) form = result['form'] content = DIV( title, form ) back = os_gui.get_button('back', return_url) return dict(content=content, #menu=menu, back=back, save=result['submit'])
def ep_index_teacher_upcoming_classes(days=3): """ @return: List upcoming classes for a teacher """ from openstudio.os_teacher import Teacher if auth.user.id and auth.user.teacher: teachers_id = auth.user.id cache_clear_classschedule() else: return '' teacher = Teacher(auth.user.id) return teacher.get_upcoming_classes_formatted(days)
def pinboard_get_teacher_sub_classes(var=None): """ Returns list of classes available for subbing """ from openstudio.os_teacher import Teacher if auth.user.id and auth.user.teacher: teachers_id = auth.user.id cache_clear_classschedule() else: return '' teacher = Teacher(auth.user.id) return teacher.get_subrequests_formatted()
def payment_fixed_rate_class(): """ Add default fixed rate for this teacher """ from openstudio.os_customer import Customer from openstudio.os_teacher import Teacher from openstudio.os_forms import OsForms teID = request.vars['teID'] clsID = request.vars['clsID'] response.view = 'general/only_content.html' customer = Customer(teID) response.title = customer.get_name() response.subtitle = T("Set class rate") record = db.classes(clsID) location = db.school_locations[record.school_locations_id].Name classtype = db.school_classtypes[record.school_classtypes_id].Name class_name = NRtoDay(record.Week_day) + ' ' + \ record.Starttime.strftime(TIME_FORMAT) + ' - ' + \ classtype + ', ' + location os_forms = OsForms() return_url = payment_fixed_rate_default_return_url(teID) db.teachers_payment_fixed_rate_class.auth_teacher_id.default = teID db.teachers_payment_fixed_rate_class.classes_id.default = clsID teacher = Teacher(teID) payment = db.teachers_payment_fixed_rate_class( classes_id = clsID, auth_teacher_id = teID ) if payment: title = H4(T('Edit class rate for'), ' ', class_name) result = os_forms.get_crud_form_update( db.teachers_payment_fixed_rate_class, return_url, payment.id ) else: title = H4(T('Add class rate for'), ' ', class_name) result = os_forms.get_crud_form_create( db.teachers_payment_fixed_rate_class, return_url, ) form = result['form'] content = DIV( title, form ) back = os_gui.get_button('back', return_url) return dict(content=content, back=back, save=result['submit'])
def ep_index_teacher_sub_classes(): """ @return: List classes that need to get subbed """ from openstudio.os_teacher import Teacher if auth.user.id and auth.user.teacher: teachers_id = auth.user.id cache_clear_classschedule() else: return '' session.ep_available_for_sub_back = 'ep_index' teacher = Teacher(auth.user.id) return teacher.get_subrequests_formatted()
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)