Exemple #1
0
class PeopleGrid(Grid):
    session_on = True

    FirstNameColumn(_('First Name'), Person.firstname, TextFilter)
    FullNameColumn(_('Full Name'))
    YesNoColumn(_('Active'), Person.inactive, reverse=True)
    EmailsColumn(_('Emails'))
    Column(_('Status'), Status.label.label('status'), StatusFilter(Status.id))
    DateTimeColumn(_('Created'), Person.createdts, DateTimeFilter)
    DateColumn(_('Due Date'), 'due_date')
    Column(_('Sort Order'), Person.sortorder, render_in='xls')
    Column(_('State'), Person.state, render_in='xlsx')
    NumericColumn(_('Number'), Person.numericcol, has_subtotal=True)
    EnumColumn(_('Account Type'), Person.account_type,
               OptionsEnumFilter(Person.account_type, enum_type=AccountType))

    def query_prep(self, query, has_sort, has_filters):
        query = query.add_columns(
            Person.id,
            Person.lastname,
            Person.due_date,
            Person.account_type,
        ).add_entity(Person).outerjoin(Person.status)

        # default sort
        if not has_sort:
            query = query.order_by(Person.id)

        return query
Exemple #2
0
 class TG(Grid):
     Column('ID', Person.id, TextFilter, can_sort=False, visible=False)
     FirstNameColumn('First Name',
                     Person.firstname,
                     TextFilter,
                     can_sort=False,
                     link_label='hi',
                     visible=False)
     YesNoColumn('Active',
                 Person.inactive,
                 TextFilter,
                 can_sort=False,
                 reverse=True,
                 visible=False)
     # DateColumn & DateTime Column are just subclasses of DateColumnBase
     # so we don't need to explicitly test both
     DateTimeColumn('Created',
                    Person.createdts,
                    DateFilter,
                    can_sort=False,
                    html_format='foo',
                    visible=False)
     NumericColumn('Address',
                   Person.address,
                   IntFilter,
                   can_sort=False,
                   visible=False)
Exemple #3
0
class WidgetGrid(Grid):
    endpoint = 'WidgetCrud'

    @property
    def has_delete(self):
        return True

    class ActionColumn(Column):
        has_edit = True

        @property
        def has_delete(self):
            return self.grid.has_delete

        def extract_data(self, rec):
            edit_link = ''
            if self.has_edit:
                edit_link = link_to('(edit)',
                                    url_for(self.grid.endpoint,
                                            action='edit',
                                            objid=rec.id,
                                            session_key=self.grid.session_key),
                                    class_='edit_link',
                                    title='edit record')
            delete_link = ''
            if self.has_delete:
                delete_link = link_to('(delete)',
                                      url_for(
                                          self.grid.endpoint,
                                          action='delete',
                                          objid=rec.id,
                                          session_key=self.grid.session_key),
                                      class_='delete_link',
                                      title='delete record')
            return literal('{0}{1}'.format(
                delete_link,
                edit_link,
            ))

    ActionColumn('Actions', orm.Widget.id)
    Column('Type', orm.Widget.widget_type)
    Column('Color', orm.Widget.color)
    Column('Quantity', orm.Widget.quantity)
    DateTimeColumn('Created', orm.Widget.createdts)
    DateTimeColumn('Last Updated', orm.Widget.updatedts)
Exemple #4
0
class ArrowCSVGrid(Grid):
    session_on = True
    allowed_export_targets = {'csv': CSV}
    DateTimeColumn(_('Created'), ArrowRecord.created_utc, DateTimeFilter)

    def query_prep(self, query, has_sort, has_filters):
        # default sort
        if not has_sort:
            query = query.order_by(ArrowRecord.id)

        return query
Exemple #5
0
class ArrowGrid(Grid):
    session_on = True

    DateTimeColumn(_('Created'), ArrowRecord.created_utc, DateTimeFilter)

    def query_prep(self, query, has_sort, has_filters):
        # default sort
        if not has_sort:
            query = query.order_by(ArrowRecord.id)

        return query
Exemple #6
0
class PeopleGrid(Grid):
    session_on = True
    allowed_export_targets = {'csv': CSV, 'xls': XLS, 'xlsx': XLSX}
    FirstNameColumn('First Name', Person.firstname, TextFilter)
    FullNameColumn('Full Name')
    YesNoColumn('Active', Person.inactive, reverse=True)
    EmailsColumn('Emails')
    Column('Status', Status.label.label('status'), StatusFilter(Status.id))
    DateTimeColumn('Created', Person.createdts, DateTimeFilter)
    DateColumn('Due Date', 'due_date')
    Column('Sort Order', Person.sortorder, render_in='xls')
    NumericColumn('Number', Person.numericcol, has_subtotal=True)

    def query_prep(self, query, has_sort, has_filters):
        query = query.add_columns(
            Person.id, Person.lastname,
            Person.due_date).add_entity(Person).outerjoin(Person.status)

        # default sort
        if not has_sort:
            query = query.order_by(Person.id)

        return query
Exemple #7
0
 class CSVGrid(Grid):
     session_on = True
     allowed_export_targets = {'csv': CSV}
     DateTimeColumn('Created',
                    ArrowRecord.created_utc,
                    csv_format='%m/%d/%Y %I:%M %p')