Exemplo n.º 1
0
    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_cashbook',
                    'additional_item_edit',
                    vars={'acaiID': row.id}))
            buttons.append(edit)
        if permission_delete:
            onclick_delete = \
                "return confirm('" + \
                T('m_openstudio_os_accounting_cashbooks_additional_items_delete_confirm') + \
                "');"

            delete = os_gui.get_button('delete_notext',
                                       URL('finance_cashbook',
                                           'additional_item_delete',
                                           vars={'acaiID': row.id}),
                                       onclick=onclick_delete)
            buttons.append(delete)

        return buttons
    def _list_formatted_get_buttons(self, row, permission_edit):
        """
        :param row:
        :param permission_edit:
        :return:
        """
        from os_gui import OsGui

        os_gui = OsGui()
        buttons = DIV(_class='pull-right')

        if permission_edit:
            edit = os_gui.get_button(
                'edit',
                URL('settings',
                    'financial_glaccount_edit',
                    vars={'agID': row.id}))
            buttons.append(edit)
            archive = os_gui.get_button(
                'archive',
                URL('settings',
                    'financial_glaccount_archive',
                    vars={'agID': row.id}))
            buttons.append(archive)

        return buttons
    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
Exemplo n.º 4
0
    def list_formatted(self):
        """
            :return: HTML table with mailing lists
        """
        from os_gui import OsGui

        T = current.T
        os_gui = OsGui()
        auth = current.auth

        header = THEAD(TR(TH(T('Name')),
                          TH(T('Description')),
                          TH(T('Frequency')),
                          TH(T('MailChimp ListID')),
                          TH()))
        table = TABLE(header, _class='table table-striped table-hover')

        permission_edit = (auth.has_membership(group_id='Admins') or
                           auth.has_permission('update', 'mailing_lists'))
        permission_delete = (auth.has_membership(group_id='Admins') or
                             auth.has_permission('delete', 'mailing_lists'))

        onclick_delete = "return confirm('" \
            + T('Do you really want to delete this list?') + ' ' \
            + "');"

        rows = self.list()
        for row in rows:
            buttons = ''
            edit = ''
            delete = ''
            vars = {'mlID':row.id}

            if permission_edit:
                edit = os_gui.get_button('edit',
                    URL('settings_mail', 'mailing_list_edit', vars=vars))

            if permission_delete:
                delete = os_gui.get_button('delete_notext',
                    URL('settings_mail', 'mailing_list_delete', vars=vars),
                    onclick=onclick_delete,
                )
            buttons = DIV(edit, delete, _class='pull-right')

            tr = TR(
                TD(os_gui.max_string_length(row.Name, 20)),
                TD(os_gui.max_string_length(row.Description, 30)),
                TD(os_gui.max_string_length(row.Frequency, 20)),
                TD(row.MailChimpListID),
                TD(buttons)
            )

            table.append(tr)

        return table
Exemplo n.º 5
0
    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
Exemplo n.º 6
0
    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
Exemplo n.º 7
0
    def _rows_to_table_buttons(self, row, permission):
        """
            This function returns the group a user belongs to and shows it as a link
            to a page which allows users to change it.
        """
        from os_gui import OsGui

        os_gui = OsGui()
        T = current.T
        db = current.db

        if not permission:
            return ''

        delete_onclick = "return confirm('" + \
                         T('Remove from teachers list? - This person will still be a customer.') + "');"

        delete = os_gui.get_button('delete_notext',
                                   URL('teachers',
                                       'delete',
                                       vars={'uID': row.id}),
                                   onclick=delete_onclick,
                                   _class='pull-right')

        links = []
        # Check Update teachers payment attendance classes
        links.append(
            A(os_gui.get_fa_icon('fa-usd'),
              T('Fixed rate payments'),
              _href=URL('teachers',
                        'payment_fixed_rate',
                        vars={'teID': row.id})))
        links.append(
            A(os_gui.get_fa_icon('fa-subway'),
              T('Travel allowance'),
              _href=URL('teachers', 'payment_travel', vars={'teID': row.id})))
        links.append('divider')
        links.append(
            A(os_gui.get_fa_icon('fa-check-square-o'),
              T('Assign classtypes'),
              _href=URL('teachers', 'edit_classtypes', vars={'uID': row.id})))
        links.append(
            A(os_gui.get_fa_icon('fa-pencil'),
              T('Edit'),
              _href=URL('customers', 'edit', args=row.id)))

        actions = os_gui.get_dropdown_menu(links=links,
                                           btn_text=T('Actions'),
                                           btn_size='btn-sm',
                                           btn_icon='actions',
                                           menu_class='btn-group pull-right')

        return DIV(delete, actions, _class='pull-right')
Exemplo n.º 8
0
    def _list_formatted_link_view(self, row):
        """
        Returns the 'view' button for a receipt
        """
        from os_gui import OsGui

        T = current.T
        os_gui = OsGui()

        return os_gui.get_button(
            'noicon',
            URL('finance', 'receipt', vars={'rID': row.id}),
            title=T("View"),
            _target="_blank"
        )
Exemplo n.º 9
0
    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
Exemplo n.º 10
0
    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
Exemplo n.º 11
0
    def list_formatted(self, status, limitby):
        """

        :return: HTML table of available sub teachers
        """
        from os_gui import OsGui

        T = current.T
        db = current.db
        os_gui = OsGui()

        table = TABLE(_class='table table-hover')

        table.append(
            THEAD(
                TR(
                    # TH(),
                    TH(T('Date')),
                    TH(T('Start')),
                    TH(T('Location')),
                    TH(T('Class Type')),
                    TH(T('Sub teacher')),
                    TH(),  # actions))
                )))

        left = [
            db.classes_otc.on(
                db.classes_otc_sub_avail.classes_otc_id == db.classes_otc.id),
            db.classes.on(db.classes_otc.classes_id == db.classes.id)
        ]

        if status == 'pending':
            query = (db.classes_otc_sub_avail.Accepted == None)
        else:
            query = ((db.classes_otc_sub_avail.Accepted == True) |
                     (db.classes_otc_sub_avail.Accepted == False))

        rows = db(query).select(db.classes_otc_sub_avail.ALL,
                                db.classes_otc.ALL,
                                db.classes.ALL,
                                left=left,
                                limitby=limitby,
                                orderby=db.classes_otc.ClassDate
                                | db.classes_otc.Starttime)

        for i, row in enumerate(rows):
            repr_row = list(rows[i:i + 1].render())[0]

            if row.classes_otc_sub_avail.Accepted == True:
                status = os_gui.get_label('success', T("Accepted"))
            elif row.classes_otc_sub_avail.Accepted == False:
                status = os_gui.get_label('danger', T("Declined"))
            else:
                status = os_gui.get_label('primary', T("Pending"))
            button = os_gui.get_button(
                'ok_notext',
                URL('sub_avail_accept',
                    vars={'cotcsaID': row.classes_otc_sub_avail.id}),
                title='Accept',
                _class='pull-right',
                btn_class='btn-success')

            button += os_gui.get_button(
                'cancel_notext',
                URL('sub_avail_decline',
                    vars={'cotcsaID': row.classes_otc_sub_avail.id}),
                title='Decline',
                _class='pull-right',
                btn_class='btn-danger')

            tr = TR(TD(repr_row.classes_otc.ClassDate),
                    TD(repr_row.classes.Starttime),
                    TD(repr_row.classes.school_locations_id),
                    TD(repr_row.classes.school_classtypes_id),
                    TD(repr_row.classes_otc_sub_avail.auth_teacher_id),
                    TD(status), TD(button))

            table.append(tr)

        return dict(table=table, rows=rows)
Exemplo n.º 12
0
    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
Exemplo n.º 13
0
    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
Exemplo n.º 14
0
    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
Exemplo n.º 15
0
    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
Exemplo n.º 16
0
    def get_subrequests_formatted(self):
        """
        :return: HTML table holding subrequests this teacher can apply for
        """
        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.classes_teachers.on(
                db.classes_teachers.classes_id == db.classes.id)
        ]

        query = ((db.classes_otc.Status == 'open') &
                 ((db.classes.school_classtypes_id.belongs(ctIDs)) |
                  (db.classes_otc.school_classtypes_id.belongs(ctIDs))) &
                 (db.classes_teachers.Startdate <= db.classes_otc.ClassDate) &
                 ((db.classes_teachers.Enddate >= db.classes_otc.ClassDate) |
                  (db.classes_teachers.Enddate == None)) &
                 (db.classes_otc.ClassDate >= TODAY_LOCAL))

        rows = db(query).select(db.classes_otc.ALL,
                                db.classes.ALL,
                                left=left,
                                orderby=db.classes.id)

        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)

            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 to sub"),
                    _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')

        ## disable for now
        return ''