def get_payment_fixed_rate_default_display(self): """ :return: HTML display of default rate for teacher """ from .os_gui import OsGui T = current.T os_gui = OsGui() display = DIV(H3(T("Default rate")), ) edit_url = URL('payment_fixed_rate_default', vars={'teID': self.id}) rows = self.get_payment_fixed_rate_default(render=True) if not rows: display.append(A(T('Set default rate'), _href=edit_url)) return display row = list(rows)[0] display.append( DIV( os_gui.get_button('edit', edit_url, _class='pull-right', title=T('Edit'), tooltip=T('Edit the default rate')), H4(row.ClassRate), ' ', row.tax_rates_id, BR(), )) return display
def _list_formatted_get_buttons(self, row, permission_edit, permission_delete): """ :param row: :param permission_edit: :return: """ from .os_gui import OsGui T = current.T os_gui = OsGui() buttons = DIV(_class='pull-right') if permission_edit: edit = os_gui.get_button( 'edit', URL('finance_expenses', 'edit', vars={'aeID': row.id}) ) buttons.append(edit) if permission_delete: onclick_delete = \ "return confirm('" + \ T('Are you sure you want to delete this expense?') + \ "');" delete = os_gui.get_button( 'delete_notext', URL('finance_expenses', 'delete', vars={'aeID': row.id}), onclick=onclick_delete ) buttons.append(delete) return buttons
def divisions(): """ List divisions """ def get_button_set_default(division_id): if division_id == selected_division: return DIV(os_gui.get_label( 'success', T('Selected'), ), _class='pull-right') else: return os_gui.get_button('noicon', URL('division_set_default', vars={'division_id': division_id}), _class='pull-right', btn_class='btn-link', title=T("Select this division")) from ConfigParser import NoOptionError from openstudio.os_exact_online import OSExactOnline from openstudio.os_gui import OsGui response.title = T("Exact online") response.subtitle = T("Divisions") response.view = 'general/only_content.html' os_gui = OsGui() os_eo = OSExactOnline() api = os_eo.get_api() storage = os_eo.get_storage() try: selected_division = int(storage.get('transient', 'division')) except NoOptionError: selected_division = None division_choices, current_division = api.get_divisions() header = THEAD(TR(TH('Name'), TH('Exact ID'), TH())) table = TABLE(header, _class="table table-striped table-hover") for division_id in division_choices: tr = TR( TD(division_choices[division_id]), TD(division_id), TD(get_button_set_default(division_id)) # buttons ) table.append(tr) content = table back = os_gui.get_button('back', URL('settings_integration', 'exact_online')) return dict(content=content, back=back)
def _get_payment_info_mandates_format(self, rows): """ :param rows: gluon.dal.rows object of db.customers_payment_info_mandates :return: """ from .os_gui import OsGui T = current.T auth = current.auth os_gui = OsGui() request = current.request delete_permission = (auth.has_membership(group_id='Admins') or auth.has_permission( 'delete', 'customers_payment_info_mandates')) edit_permission = (auth.has_membership(group_id='Admins') or auth.has_permission( 'update', 'customers_payment_info_mandates')) onclick = "return confirm('" + \ T('Do you really want to remove this mandate?') + "');" mandates = DIV() for row in rows.render(): btn_delete = '' box_tools = DIV(_class='box-tools') if delete_permission and request.controller == 'customers': box_tools.append( A(os_gui.get_fa_icon('fa-times'), _href=URL('customers', 'bankaccount_mandate_delete', vars={ 'cuID': self.cuID, 'cpimID': row.id }), _onclick=onclick, _class='btn-box-tool text-red')) mandates.append( DIV(DIV(H3(T("Direct debit mandate"), _class="box-title"), box_tools, _class="box-header"), DIV(LABEL(T("Reference")), DIV(row.MandateReference), LABEL(T("Signed on")), DIV(row.MandateSignatureDate), LABEL(T("Mandate content")) if row.MandateText else '', DIV(XML(row.MandateText)), _class="box-body"), _class="box box-solid")) return mandates
def financial_glaccounts(): """ List G/L accounts """ from ConfigParser import NoOptionError from openstudio.os_exact_online import OSExactOnline from exactonline.exceptions import ObjectDoesNotExist from exactonline.resource import GET, POST, PUT, DELETE from openstudio.os_gui import OsGui response.title = T("Exact online") response.subtitle = T("G/L Accounts") response.view = 'general/only_content.html' os_gui = OsGui() os_eo = OSExactOnline() api = os_eo.get_api() storage = os_eo.get_storage() try: selected_division = int(storage.get('transient', 'division')) except NoOptionError: selected_division = None items = api.financialglaccounts.all() sorted_items = sorted(items, key=lambda k: k['Code']) header = THEAD( TR( TH('G/L Account code'), TH('G/L Account Description'), TH('G/L Account ID'), )) table = TABLE(header, _class="table table-striped table-hover") for item in sorted_items: tr = TR(TD(item['Code']), TD(item['Description']), TD(item['ID'])) table.append(tr) content = table back = os_gui.get_button('back', URL('settings_integration', 'exact_online')) return dict(content=content, back=back)
def _list_sqlform_grid_link_edit(self, row): """ :param row: :return: """ from .os_gui import OsGui auth = current.auth os_gui = OsGui() edit = '' permission = auth.has_membership(group_id='Admins') or \ auth.has_permission('update', 'accounting_expenses') if permission: edit = os_gui.get_button( 'edit', URL('finance_expenses', 'edit', vars={'aeID': row.id}) ) return edit
def get_add(self, button_text=None, btn_size='btn-sm', redirect_vars={}): """ :return: Returns an html add button for an account """ from openstudio.os_gui import OsGui os_gui = OsGui() add = os_gui.get_button( 'add', URL('customers', 'add', vars=redirect_vars), _class='pull-right', btn_size=btn_size, title=button_text ) return add
def _classes_reservation_add_get_button(self, clsID): """ Returns add button for a customer to add a reservation """ from .os_customer import Customer from .os_gui import OsGui os_gui = OsGui() session = current.session DATE_FORMAT = current.DATE_FORMAT date = session.customers_classes_reservation_add_vars['date'] date_formatted = date.strftime(DATE_FORMAT) cuID = session.customers_classes_reservation_add_vars['cuID'] customer = Customer(cuID) add = os_gui.get_button('add', URL('classes', 'reservation_add_choose', vars={'cuID': cuID, 'clsID': clsID, 'date': date_formatted}), btn_size='btn-sm', _class="pull-right") return add
def get_prices_for_class_display(self, clsID): """ Get table to display prices for a class :param clsID: db.classes.id :return: HTML table """ from openstudio.os_gui import OsGui os_gui = OsGui() auth = current.auth rows = self.get_prices_for_class(clsID) table = TABLE(self._get_prices_for_class_display_header(), _class="table table-striped table-hover") edit_permission = (auth.has_membership(group_id='Admins') or auth.has_permission('update', 'classes_price')) delete_permission = (auth.has_membership(group_id='Admins') or auth.has_permission('delete', 'classes_price')) for i, row in enumerate(rows): repr_row = list(rows[i:i + 1].render())[0] tr = TR( TD(repr_row.Startdate), TD(repr_row.Enddate), TD(repr_row.Dropin, BR(), repr_row.tax_rates_id_dropin), TD( SPAN(repr_row.DropinMembership, BR(), repr_row. tax_rates_id_dropin_membership) if row. DropinMembership else ''), TD(repr_row.accounting_glaccounts_id_dropin), TD(repr_row.Trial, BR(), repr_row.tax_rates_id_trial), TD( SPAN(repr_row.TrialMembership, BR(), repr_row. tax_rates_id_trial_membership) if row. TrialMembership else ''), TD(repr_row.accounting_glaccounts_id_trial), TD( self._get_prices_for_class_display_buttons( os_gui, row, edit_permission, delete_permission))) table.append(tr) return table
def list_sqlform_grid(self, date_from=None, date_until=None): """ SQLFORM.grid for accounting_expenses :param date_from: :param date_until: :return: """ db = current.db auth = current.auth session = current.session grid_ui = current.globalenv['grid_ui'] DATE_FORMAT = current.DATE_FORMAT from general_helpers import datestr_to_python from openstudio.os_gui import OsGui os_gui = OsGui() T = current.T query = (db.accounting_expenses.id > 0) links = [ self._list_sqlform_grid_link_edit, ] delete_permission = auth.has_membership(group_id='Admins') or \ auth.has_permission('delete', 'accounting_expenses') grid = SQLFORM.grid(query, links=links, # left=left, field_id=db.accounting_expenses.id, # fields=fields, create=False, editable=False, details=False, searchable=False, deletable=delete_permission, csv=False, # maxtextlengths=maxtextlengths, orderby=~db.accounting_expenses.id, ui=grid_ui) grid.element('.web2py_counter', replace=None) # remove the counter grid.elements('span[title=Delete]', replace=None) # remove text from delete button return grid
def get_payment_fixed_rate_classes_display(self): """ :return: gluon.dal.row object of db.teachers_payment_fixed_rate_class """ from openstudio.os_gui import OsGui T = current.T auth = current.auth os_gui = OsGui() rows = self.get_payment_fixed_rate_classes_rows() display = DIV( os_gui.get_button('add', URL('teachers', 'payment_fixed_rate_class_add', vars={'teID': self.id}), _class='pull-right'), H3(T("Class rates")), ) if not rows: return display edit_permission = auth.has_membership(group_id='Admins') or \ auth.has_permission('update', 'teachers_payment_fixed_rate_class') delete_permission = auth.has_membership(group_id='Admins') or \ auth.has_permission('delete', 'teachers_payment_fixed_rate_class') delete_onclick = "return confirm('" + \ T('Do you really want to delete this class rate?') \ + "');" table = TABLE( self._get_payment_fixed_rate_classes_display_get_table_header(), _class='table table-hover table-striped') for i, row in enumerate(rows): repr_row = list(rows[i:i + 1].render())[0] buttons = DIV(_class='pull-right') if edit_permission: edit_url = URL( 'payment_fixed_rate_class', vars={ 'teID': self.id, 'clsID': row.teachers_payment_fixed_rate_class.classes_id }) buttons.append(os_gui.get_button('edit', edit_url)) if delete_permission: delete_url = URL('payment_fixed_rate_class_delete', vars={ 'tpfrcID': row.teachers_payment_fixed_rate_class.id, 'teID': self.id }) buttons.append( os_gui.get_button( 'delete_notext', delete_url, onclick=delete_onclick, )) time = SPAN(repr_row.classes.Starttime, ' - ', repr_row.classes.Endtime) table.append( TR(TD(repr_row.classes.Week_day), TD(time), TD(repr_row.classes.school_classtypes_id), TD(repr_row.classes.school_locations_id), TD(repr_row.teachers_payment_fixed_rate_class.ClassRate), TD(repr_row.teachers_payment_fixed_rate_class.tax_rates_id), TD(buttons))) display.append(table) return display
def get_upcoming_classes_formatted(self, days=3): """ Returns upcoming classes for teacher """ from .os_gui import OsGui from .os_class_schedule import ClassSchedule T = current.T db = current.db auth = current.auth os_gui = OsGui() DATE_FORMAT = current.DATE_FORMAT TODAY_LOCAL = current.globalenv['TODAY_LOCAL'] attendance_permission = (auth.has_membership(group_id='Admins') or auth.has_permission( 'update', 'classes_attendance')) date = TODAY_LOCAL delta = datetime.timedelta(days=1) header = THEAD( TR( TH(T('Class date')), TH(T('Time')), TH(T('Location')), TH(T('Class type')), TH(T('Teacher')), TH(T('Teacher2')), TH(), )) table = TABLE(header, _class='table table-hover') for day in range(0, days): cs = ClassSchedule(date, filter_id_teacher=self.id) rows = cs.get_day_rows() for i, row in enumerate(rows): if row.classes_otc.Status == 'cancelled' or row.school_holidays.id: continue repr_row = list(rows[i:i + 1].render())[0] result = cs._get_day_row_teacher_roles(row, repr_row) teacher = result['teacher_role'] teacher2 = result['teacher_role2'] attendance = '' if attendance_permission: attendance = os_gui.get_button( 'noicon', URL('classes', 'attendance', vars={ 'clsID': row.classes.id, 'date': date.strftime(DATE_FORMAT) }), title=T('Attendance'), _class=T('pull-right')) tr = TR( TD(date.strftime(DATE_FORMAT), _class='bold green' if day == 0 else ''), TD(repr_row.classes.Starttime, ' - ', repr_row.classes.Endtime), TD(repr_row.classes.school_locations_id), TD(repr_row.classes.school_classtypes_id), TD(teacher), TD(teacher2), TD(attendance)) table.append(tr) date += delta upcoming_classes = DIV( DIV(H3(T('My upcoming classes'), _class="box-title"), DIV(A(I(_class='fa fa-minus'), _href='#', _class='btn btn-box-tool', _title=T("Collapse"), **{'_data-widget': 'collapse'}), _class='box-tools pull-right'), _class='box-header with-border'), DIV(table, _class='box-body'), self._get_teacher_upcoming_classes_formatted_footer(), _class='box box-primary') return upcoming_classes
def get_subrequests_formatted(self): """ :return: HTML table holding subrequests this teacher can apply for """ from .os_class import Class from .os_gui import OsGui os_gui = OsGui() T = current.T db = current.db auth = current.auth TODAY_LOCAL = current.TODAY_LOCAL header = THEAD( TR(TH(T('Class date')), TH(T('Time')), TH(T('Location')), TH(T('Class type')), TH())) table = TABLE(header, _class='table table-hover') # Get classtypes for currently logged on teacher query = (db.teachers_classtypes.auth_user_id == self.id) rows = db(query).select(db.teachers_classtypes.school_classtypes_id) ctIDs = [row.school_classtypes_id for row in rows] left = [ db.classes.on(db.classes_otc.classes_id == db.classes.id, ), db.school_locations.on( db.classes.school_locations_id == db.school_locations.id) ] query = (db.classes_otc.Status == 'open') & \ ((db.classes.school_classtypes_id.belongs(ctIDs)) | (db.classes_otc.school_classtypes_id.belongs(ctIDs))) & \ (db.classes_otc.ClassDate >= TODAY_LOCAL) rows = db(query).select(db.classes_otc.ALL, db.classes.ALL, left=left, orderby=db.classes_otc.ClassDate | db.classes.Starttime | db.school_locations.Name) for i, row in enumerate(rows): repr_row = list(rows[i:i + 1].render())[0] row_avail = db.classes_otc_sub_avail( classes_otc_id=row.classes_otc.id, auth_teacher_id=auth.user.id) 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'] == self.id: continue if not row_avail: button = os_gui.get_button( 'noicon', URL('ep', 'available_for_sub', vars={'cotcID': row.classes_otc.id}), title=T("I'm available"), _class='pull-right', btn_class='btn-success') else: button = os_gui.get_button('noicon', URL('ep', 'cancel_available_for_sub', vars={'cotcsaID': row_avail.id}), title=T("I'm no longer available"), _class='pull-right', btn_class='btn-warning') tr = TR( TD(repr_row.classes_otc.ClassDate), TD(repr_row.classes.Starttime, ' - ', repr_row.classes.Endtime), TD(repr_row.classes.school_locations_id), TD(repr_row.classes.school_classtypes_id), TD(button)) table.append(tr) if not len(rows): table = T("No one is looking for a sub at the moment...") sub_requests = DIV(DIV(H3(T('Can you sub a class?'), _class="box-title"), DIV(A(I(_class='fa fa-minus'), _href='#', _class='btn btn-box-tool', _title=T("Collapse"), **{'_data-widget': 'collapse'}), _class='box-tools pull-right'), _class='box-header with-border'), DIV(table, _class='box-body'), _class='box box-success') return sub_requests
def get_notes_formatted(self, note_type, permission_edit=False, permission_delete=False): """ :param note_type: ['backoffice', 'teachers'] :return: HTML formatted notes using AdminLTE chat layout """ from openstudio.os_gui import OsGui os_gui = OsGui() T = current.T delete_onclick = "return confirm('" + T( 'Are you sure you want to delete this note?') + "');" rows = self.get_notes(note_type=note_type) notes = DIV(_class='direct-chat-messages direct-chat-messages-high') for i, row in enumerate(rows): repr_row = list(rows[i:i + 1].render())[0] edit = '' delete = '' if permission_delete: delete = A(T('Delete'), _href=URL('customers', 'note_delete', vars={ 'cnID': row.id, 'cuID': self.cuID }), _onclick=delete_onclick, _class='text-red') if permission_edit: edit = A( T('Edit'), _href=URL('customers', 'notes', vars={ 'cnID': row.id, 'cuID': self.cuID, 'note_type': note_type }), ) status = "" if row.Processed: status = SPAN(os_gui.get_fa_icon('fa-check'), ' ', T("Processed"), _class="direct-chat-scope pull-right text-green") note = DIV(DIV(SPAN(repr_row.auth_user_id, _class="direct-chat-name pull-left"), SPAN(delete, _class="direct-chat-scope pull-right"), SPAN(edit, _class="direct-chat-scope pull-right"), status, SPAN(repr_row.NoteDate, ' ', repr_row.NoteTime, ' ', _class="direct-chat-timestamp pull-right"), _class="direct-chat-info clearfix"), IMG(_src=URL('static', 'images/person_inverted_small.png'), _class="direct-chat-img"), DIV(XML(repr_row.Note.replace('\n', '<br>')), _class="direct-chat-text"), _class="direct-chat-msg") notes.append(note) return notes
def get_payment_travel_display(self): """ :return: gluon.dal.row object of db.teachers_payment_travel """ from openstudio.os_gui import OsGui T = current.T auth = current.auth os_gui = OsGui() rows = self.get_payment_travel_allowances() display = DIV() if not rows: return display edit_permission = auth.has_membership(group_id='Admins') or \ auth.has_permission('update', 'teachers_payment_travel') delete_permission = auth.has_membership(group_id='Admins') or \ auth.has_permission('delete', 'teachers_payment_travel') delete_onclick = "return confirm('" + \ T('Do you really want to delete the travel allowance for this location?') \ + "');" table = TABLE(self._get_payment_travel_display_get_table_header(), _class='table table-hover table-striped') for i, row in enumerate(rows): repr_row = list(rows[i:i + 1].render())[0] buttons = DIV(_class='pull-right') if edit_permission: edit_url = URL('payment_travel_edit', vars={ 'teID': self.id, 'tpfrtID': row.teachers_payment_travel.id }) buttons.append(os_gui.get_button('edit', edit_url)) if delete_permission: delete_url = URL('payment_travel_delete', vars={ 'tpfrtID': row.teachers_payment_travel.id, 'teID': self.id }) buttons.append( os_gui.get_button( 'delete_notext', delete_url, onclick=delete_onclick, )) table.append( TR(TD(row.school_locations.Name), TD(repr_row.teachers_payment_travel.TravelAllowance), TD(repr_row.teachers_payment_travel.tax_rates_id), TD(buttons))) display.append(table) return display
def list_invoices(self, cuID=None, csID=None, search_enabled=False, group_filter_enabled=False, only_teacher_credit_invoices=False, only_employee_claim_credit_invoices=False): db = current.db auth = current.auth session = current.session grid_ui = current.globalenv['grid_ui'] DATE_FORMAT = current.DATE_FORMAT from general_helpers import datestr_to_python from openstudio.os_gui import OsGui os_gui = OsGui() T = current.T session.invoices_invoice_payment_add_back = None # disable unused fields db.invoices.id.readable = False db.invoices.invoices_groups_id.readable = False db.invoices.Footer.readable = False db.invoices.Note.readable = False db.invoices.Terms.readable = False db.invoices.TeacherPayment.readable = False db.invoices.EmployeeClaim.readable = False links = [ dict(header=T("Balance"), body=self._list_invoices_get_balance), lambda row: os_gui.get_label('primary', T('Teacher inv')) if row.invoices.TeacherPayment else '', self._list_invoices_get_buttons ] left = [ db.invoices_amounts.on( db.invoices_amounts.invoices_id == db.invoices.id), db.invoices_customers.on( db.invoices_customers.invoices_id == db.invoices.id), db.auth_user.on( db.invoices_customers.auth_customer_id == db.auth_user.id) ] fields = [ db.invoices.Status, db.invoices.InvoiceID, db.invoices.Description, db.invoices.DateCreated, db.invoices.DateDue, db.invoices_amounts.TotalPriceVAT, db.invoices.TeacherPayment ] query = (db.invoices.id > 0) # Status filter query = self._list_invoices_get_status_query(query) if search_enabled: query = self._list_invoices_get_search_query(query) if group_filter_enabled: query = self._list_invoices_get_groups_query(query) if only_teacher_credit_invoices: query &= (db.invoices.TeacherPayment == True) if only_employee_claim_credit_invoices: query &= (db.invoices.EmployeeClaim == True) # General list, list for customer or list for subscription if not cuID and not csID: # list all invoices fields.insert(2, db.invoices.CustomerListName) if cuID: query &= (db.invoices_customers.auth_customer_id == cuID) if csID: left.extend([ db.invoices_items.on( db.invoices_items.invoices_id == db.invoices.id), db.invoices_items_customers_subscriptions.on( db.invoices_items_customers_subscriptions.invoices_items_id == db.invoices_items.id), ]) query &= (db.invoices_items_customers_subscriptions. customers_subscriptions_id == csID) fields.insert(3, db.invoices.SubscriptionMonth) fields.insert(4, db.invoices.SubscriptionYear) delete_permission = auth.has_membership(group_id='Admins') or \ auth.has_permission('delete', 'invoices') grid = SQLFORM.grid( query, links=links, left=left, field_id=db.invoices.id, fields=fields, create=False, editable=False, details=False, searchable=False, deletable=delete_permission, csv=False, # maxtextlengths=maxtextlengths, orderby=~db.invoices.id, ui=grid_ui) grid.element('.web2py_counter', replace=None) # remove the counter grid.elements('span[title=Delete]', replace=None) # remove text from delete button form_search = '' content = DIV() if search_enabled: #response.js = 'set_form_classes();' # we're no longer in a loaded component request = current.request if 'search' in request.vars: session.invoices_list_invoices_search = request.vars['search'] # date_created_from = datestr_to_python(DATE_FORMAT, request.vars['date_created_from']) # session.invoices_list_invoices_date_created_from = date_created_from try: date_created_from = datestr_to_python( DATE_FORMAT, request.vars['date_created_from']) session.invoices_list_invoices_date_created_from = date_created_from except (ValueError, AttributeError): session.invoices_list_invoices_date_created_from = None try: date_created_until = datestr_to_python( DATE_FORMAT, request.vars['date_created_until']) session.invoices_list_invoices_date_created_until = date_created_until except (ValueError, AttributeError): session.invoices_list_invoices_date_created_until = None try: date_due_from = datestr_to_python( DATE_FORMAT, request.vars['date_due_from']) session.invoices_list_invoices_date_due_from = date_due_from except (ValueError, AttributeError): session.invoices_list_invoices_date_due_from = None try: date_due_until = datestr_to_python( DATE_FORMAT, request.vars['date_due_until']) session.invoices_list_invoices_date_due_until = date_due_until except (ValueError, AttributeError): session.invoices_list_invoices_date_due_until = None keys = [ 'search', 'date_created_from', 'date_created_until', 'date_due_from', 'date_due_until' ] for key in keys: try: del request.vars[key] except KeyError: pass # redirect to update page redirect(URL(vars=request.vars)) form_search = self._list_invoices_get_form_search() content.append(form_search) form_groups = '' if group_filter_enabled: if 'invoices_groups_id' in request.vars: session.invoices_list_invoices_group = request.vars[ 'invoices_groups_id'] try: del request.vars['invoices_groups_id'] except KeyError: pass # redirect to update page redirect(URL(vars=request.vars)) # always add the grid content.append(grid) return content
passwd = ''.join(random.SystemRandom().choice(chars) for _ in xrange(length)) return passwd def LTE_MENU(menu, _class, li_class, ul_class): lte_menu = MENU(menu, _class=_class, li_class=li_class, ul_class=ul_class) lte_menu['_data-widget'] = "tree" return lte_menu CACHE_LONG = myconf.get('cache.max_cache_time') # 3 days GENDERS = set_genders() VALIDITY_UNITS = set_validity_units() SUBSCRIPTION_UNITS = set_subscription_units() teachers_roles = set_teachers_roles() payment_statuses = set_payment_statuses() message_statuses = set_message_statuses() invoice_statuses = set_invoice_statuses() order_statuses = set_order_statuses() booking_statuses = set_booking_statuses() payment_batchtypes = set_payment_batchtypes() teacher_payment_classes_statuses = set_teachers_payment_classes_statuses() teacher_payment_classes_rate_types = set_teacher_payment_classes_rate_types() customers_orders_origins = set_customers_orders_origins() employee_expenses_statuses = set_employee_expenses_statuses() os_gui = OsGui()
def classes_add_get_list(self, date, list_type, cuID=None, teID=None): """ Get list of classes for a date list_type is expected to be in [ 'attendance', 'reservations', 'tp_fixed_rate' ] """ from .os_attendance_helper import AttendanceHelper from .os_class_schedule import ClassSchedule from .os_gui import OsGui T = current.T db = current.db os_gui = OsGui() DATE_FORMAT = current.DATE_FORMAT session = current.session if list_type == 'attendance': session.classes_attendance_signin_back = 'cu_classes_attendance' ah = AttendanceHelper() # links = [ lambda row: ah.get_signin_buttons(row.classes.id, date, cuID) ] if session.classes_schedule_sort == 'location': orderby = db.school_locations.Name | db.classes.Starttime elif session.classes_schedule_sort == 'starttime': orderby = db.classes.Starttime | db.school_locations.Name else: orderby = db.school_locations.Name | db.classes.Starttime filter_id_teacher = None if list_type == 'tp_fixed_rate': filter_id_teacher = cuID cs = ClassSchedule(date, sorting=orderby, filter_id_teacher=filter_id_teacher) classes = cs.get_day_list() header = THEAD(TR(TH(T('Time')), TH(T('Location')), TH(T('Class')), TH(), TH() # buttons )) table = TABLE(header, _class='table table-striped table-hover') for c in classes: status = self._classes_add_get_list_get_cancelled_holiday(c) buttons = '' if list_type == 'reservations': buttons = self._classes_reservation_add_get_button(c['ClassesID']) elif list_type == 'attendance' and status == '': buttons = os_gui.get_button('noicon', URL('customers', 'classes_attendance_add_booking_options', vars={'cuID': cuID, 'clsID': c['ClassesID'], 'date': date.strftime(DATE_FORMAT)}), title='Check in', _class='pull-right') elif list_type == 'tp_fixed_rate': buttons = os_gui.get_button( 'noicon', URL('teachers', 'payment_fixed_rate_class', vars={'teID': teID, 'clsID': c['ClassesID']}), title=T('Set rate'), _class='pull-right' ) tr = TR( TD(c['Starttime'], ' - ', c['Endtime']), TD(c['Location']), TD(c['ClassType']), TD(status), TD(buttons) ) table.append(tr) return table