Refactor views to use Grid.set_sort_defaults()
method
This commit is contained in:
parent
7d79727c2e
commit
4902fab187
|
@ -70,8 +70,7 @@ class BatchMasterView2(MasterView2, BatchMasterView):
|
|||
g.sorters['created_by'] = g.make_sorter(model.User.username)
|
||||
g.sorters['executed_by'] = g.make_sorter(model.User.username)
|
||||
|
||||
g.default_sortkey = 'id'
|
||||
g.default_sortdir = 'desc'
|
||||
g.set_sort_defaults('id', 'desc')
|
||||
|
||||
g.set_enum('status_code', self.model_class.STATUS)
|
||||
|
||||
|
@ -99,7 +98,7 @@ class BatchMasterView2(MasterView2, BatchMasterView):
|
|||
|
||||
g.filters['status_code'].set_value_renderer(grids.filters.EnumValueRenderer(self.model_row_class.STATUS))
|
||||
|
||||
g.default_sortkey = 'sequence'
|
||||
g.set_sort_defaults('sequence')
|
||||
|
||||
g.set_enum('status_code', self.model_row_class.STATUS)
|
||||
|
||||
|
|
|
@ -83,8 +83,7 @@ class EmailBouncesView(MasterView):
|
|||
g.filters['processed'].default_verb = 'is_null'
|
||||
g.filters['processed_by'] = g.make_filter('processed_by', model.User.username)
|
||||
g.sorters['processed_by'] = g.make_sorter(model.User.username)
|
||||
g.default_sortkey = 'bounced'
|
||||
g.default_sortdir = 'desc'
|
||||
g.set_sort_defaults('bounced', 'desc')
|
||||
|
||||
g.set_label('config_key', "Source")
|
||||
g.set_label('bounce_recipient_address', "Bounced To")
|
||||
|
|
|
@ -50,7 +50,7 @@ class BrandsView(MasterView):
|
|||
super(BrandsView, self).configure_grid(g)
|
||||
g.filters['name'].default_active = True
|
||||
g.filters['name'].default_verb = 'contains'
|
||||
g.default_sortkey = 'name'
|
||||
g.set_sort_defaults('name')
|
||||
g.set_link('name')
|
||||
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ class CategoriesView(MasterView):
|
|||
super(CategoriesView, self).configure_grid(g)
|
||||
g.filters['name'].default_active = True
|
||||
g.filters['name'].default_verb = 'contains'
|
||||
g.default_sortkey = 'code'
|
||||
g.set_sort_defaults('code')
|
||||
g.set_link('code')
|
||||
g.set_link('number')
|
||||
g.set_link('name')
|
||||
|
|
|
@ -57,7 +57,7 @@ class CustomerGroupsView(MasterView):
|
|||
super(CustomerGroupsView, self).configure_grid(g)
|
||||
g.filters['name'].default_active = True
|
||||
g.filters['name'].default_verb = 'contains'
|
||||
g.default_sortkey = 'name'
|
||||
g.set_sort_defaults('name')
|
||||
g.set_link('id')
|
||||
g.set_link('name')
|
||||
|
||||
|
|
|
@ -104,7 +104,7 @@ class CustomersView(MasterView):
|
|||
g.sorters['email'] = lambda q, d: q.order_by(getattr(model.CustomerEmailAddress.address, d)())
|
||||
g.sorters['phone'] = lambda q, d: q.order_by(getattr(model.CustomerPhoneNumber.number, d)())
|
||||
|
||||
g.default_sortkey = 'name'
|
||||
g.set_sort_defaults('name')
|
||||
|
||||
g.set_label('id', "ID")
|
||||
g.set_label('phone', "Phone Number")
|
||||
|
|
|
@ -95,8 +95,7 @@ class CustomerOrderItemsView(MasterView):
|
|||
g.set_sorter('person', model.Person.display_name)
|
||||
g.set_sorter('order_created', model.CustomerOrder.created)
|
||||
|
||||
g.default_sortkey = 'order_created'
|
||||
g.default_sortdir = 'desc'
|
||||
g.set_sort_defaults('order_created', 'desc')
|
||||
|
||||
g.set_type('case_quantity', 'quantity')
|
||||
g.set_type('cases_ordered', 'quantity')
|
||||
|
|
|
@ -75,8 +75,7 @@ class CustomerOrdersView(MasterView):
|
|||
g.set_sorter('customer', model.Customer.name)
|
||||
g.set_sorter('person', model.Person.display_name)
|
||||
|
||||
g.default_sortkey = 'created'
|
||||
g.default_sortdir = 'desc'
|
||||
g.set_sort_defaults('created', 'desc')
|
||||
|
||||
# TODO: enum choices renderer
|
||||
g.set_label('status_code', "Status")
|
||||
|
|
|
@ -60,7 +60,7 @@ class DataSyncChangesView(MasterView):
|
|||
|
||||
def configure_grid(self, g):
|
||||
super(DataSyncChangesView, self).configure_grid(g)
|
||||
g.default_sortkey = 'obtained'
|
||||
g.set_sort_defaults('obtained')
|
||||
g.set_type('obtained', 'datetime')
|
||||
|
||||
def restart(self):
|
||||
|
|
|
@ -54,7 +54,7 @@ class DepartmentsView(MasterView):
|
|||
super(DepartmentsView, self).configure_grid(g)
|
||||
g.filters['name'].default_active = True
|
||||
g.filters['name'].default_verb = 'contains'
|
||||
g.default_sortkey = 'number'
|
||||
g.set_sort_defaults('number')
|
||||
g.set_type('product', 'boolean')
|
||||
g.set_type('personnel', 'boolean')
|
||||
g.set_link('number')
|
||||
|
|
|
@ -50,7 +50,7 @@ class DepositLinksView(MasterView):
|
|||
super(DepositLinksView, self).configure_grid(g)
|
||||
g.filters['description'].default_active = True
|
||||
g.filters['description'].default_verb = 'contains'
|
||||
g.default_sortkey = 'code'
|
||||
g.set_sort_defaults('code')
|
||||
g.set_type('amount', 'currency')
|
||||
g.set_link('code')
|
||||
g.set_link('description')
|
||||
|
|
|
@ -83,7 +83,7 @@ class ProfilesView(MasterView):
|
|||
g.sorters['subject'] = g.make_simple_sorter('subject', foldcase=True)
|
||||
g.sorters['to'] = g.make_simple_sorter('to', foldcase=True)
|
||||
g.sorters['enabled'] = g.make_simple_sorter('enabled')
|
||||
g.default_sortkey = 'key'
|
||||
g.set_sort_defaults('key')
|
||||
g.set_type('enabled', 'boolean')
|
||||
g.set_renderer('to', self.render_to)
|
||||
g.set_link('key')
|
||||
|
|
|
@ -110,7 +110,7 @@ class EmployeesView(MasterView):
|
|||
g.sorters['email'] = lambda q, d: q.order_by(getattr(model.EmployeeEmailAddress.address, d)())
|
||||
g.sorters['phone'] = lambda q, d: q.order_by(getattr(model.EmployeePhoneNumber.number, d)())
|
||||
|
||||
g.default_sortkey = 'first_name'
|
||||
g.set_sort_defaults('first_name')
|
||||
|
||||
g.set_enum('status', self.enum.EMPLOYEE_STATUS)
|
||||
|
||||
|
|
|
@ -69,8 +69,7 @@ class ExportMasterView(MasterView):
|
|||
g.joiners['created_by'] = lambda q: q.join(model.User)
|
||||
g.sorters['created_by'] = g.make_sorter(model.User.username)
|
||||
g.filters['created_by'] = g.make_filter('created_by', model.User.username)
|
||||
g.default_sortkey = 'created'
|
||||
g.default_sortdir = 'desc'
|
||||
g.set_sort_defaults('created', 'desc')
|
||||
|
||||
g.set_renderer('id', self.render_id)
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ class FamiliesView(MasterView):
|
|||
def configure_grid(self, g):
|
||||
g.filters['name'].default_active = True
|
||||
g.filters['name'].default_verb = 'contains'
|
||||
g.default_sortkey = 'code'
|
||||
g.set_sort_defaults('code')
|
||||
|
||||
def configure_fieldset(self, fs):
|
||||
fs.configure(
|
||||
|
|
|
@ -53,7 +53,7 @@ class ProfilesView(MasterView):
|
|||
|
||||
def configure_grid(self, g):
|
||||
super(ProfilesView, self).configure_grid(g)
|
||||
g.default_sortkey = 'ordinal'
|
||||
g.set_sort_defaults('ordinal')
|
||||
g.set_type('visible', 'boolean')
|
||||
g.set_link('code')
|
||||
g.set_link('description')
|
||||
|
|
|
@ -404,8 +404,7 @@ class MasterView2(MasterView):
|
|||
pass
|
||||
|
||||
def configure_version_grid(self, g):
|
||||
g.default_sortkey = 'issued_at'
|
||||
g.default_sortdir = 'desc'
|
||||
g.set_sort_defaults('issued_at', 'desc')
|
||||
g.set_renderer('comment', self.render_version_comment)
|
||||
g.set_label('issued_at', "Changed")
|
||||
g.set_label('user', "Changed by")
|
||||
|
|
|
@ -119,8 +119,7 @@ class MessagesView(MasterView):
|
|||
g.filters['subject'].default_active = True
|
||||
g.filters['subject'].default_verb = 'contains'
|
||||
|
||||
g.default_sortkey = 'sent'
|
||||
g.default_sortdir = 'desc'
|
||||
g.set_sort_defaults('sent', 'desc')
|
||||
|
||||
g.set_renderer('sent', self.render_sent)
|
||||
g.set_renderer('sender', self.render_sender)
|
||||
|
|
|
@ -92,7 +92,7 @@ class PeopleView(MasterView):
|
|||
g.sorters['email'] = lambda q, d: q.order_by(getattr(model.PersonEmailAddress.address, d)())
|
||||
g.sorters['phone'] = lambda q, d: q.order_by(getattr(model.PersonPhoneNumber.number, d)())
|
||||
|
||||
g.default_sortkey = 'display_name'
|
||||
g.set_sort_defaults('display_name')
|
||||
|
||||
g.set_label('display_name', "Full Name")
|
||||
g.set_label('phone', "Phone Number")
|
||||
|
|
|
@ -220,7 +220,7 @@ class ProductsView(MasterView):
|
|||
g.set_sorter('current_price', self.CurrentPrice.price)
|
||||
g.set_filter('current_price', self.CurrentPrice.price, label="Current Price")
|
||||
|
||||
g.default_sortkey = 'upc'
|
||||
g.set_sort_defaults('upc')
|
||||
|
||||
if self.print_labels and self.request.has_perm('products.print_labels'):
|
||||
g.more_actions.append(grids.GridAction('print_label', icon='print'))
|
||||
|
|
|
@ -146,8 +146,7 @@ class PurchaseView(MasterView):
|
|||
g.filters['date_ordered'].default_active = True
|
||||
g.filters['date_ordered'].default_verb = 'equal'
|
||||
|
||||
g.default_sortkey = 'date_ordered'
|
||||
g.default_sortdir = 'desc'
|
||||
g.set_sort_defaults('date_ordered', 'desc')
|
||||
|
||||
g.set_enum('status', self.enum.PURCHASE_STATUS)
|
||||
|
||||
|
@ -212,7 +211,7 @@ class PurchaseView(MasterView):
|
|||
def configure_row_grid(self, g):
|
||||
super(PurchaseView, self).configure_row_grid(g)
|
||||
|
||||
g.default_sortkey = 'sequence'
|
||||
g.set_sort_defaults('sequence')
|
||||
|
||||
g.set_type('cases_ordered', 'quantity')
|
||||
g.set_type('units_ordered', 'quantity')
|
||||
|
|
|
@ -67,8 +67,7 @@ class PurchaseCreditView(MasterView):
|
|||
g.set_joiner('vendor', lambda q: q.outerjoin(model.Vendor))
|
||||
g.set_sorter('vendor', model.Vendor.name)
|
||||
|
||||
g.default_sortkey = 'date_received'
|
||||
g.default_sortdir = 'desc'
|
||||
g.set_sort_defaults('date_received', 'desc')
|
||||
|
||||
g.filters['status'].set_value_renderer(grids.filters.EnumValueRenderer(self.enum.PURCHASE_CREDIT_STATUS))
|
||||
g.filters['status'].default_active = True
|
||||
|
|
|
@ -48,7 +48,7 @@ class ReportCodesView(MasterView):
|
|||
super(ReportCodesView, self).configure_grid(g)
|
||||
g.filters['name'].default_active = True
|
||||
g.filters['name'].default_verb = 'contains'
|
||||
g.default_sortkey = 'code'
|
||||
g.set_sort_defaults('code')
|
||||
g.set_link('code')
|
||||
g.set_link('name')
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ class RolesView(PrincipalMasterView):
|
|||
super(RolesView, self).configure_grid(g)
|
||||
g.filters['name'].default_active = True
|
||||
g.filters['name'].default_verb = 'contains'
|
||||
g.default_sortkey = 'name'
|
||||
g.set_sort_defaults('name')
|
||||
g.set_link('name')
|
||||
|
||||
def _preconfigure_fieldset(self, fs):
|
||||
|
|
|
@ -51,7 +51,7 @@ class SettingsView(MasterView):
|
|||
super(SettingsView, self).configure_grid(g)
|
||||
g.filters['name'].default_active = True
|
||||
g.filters['name'].default_verb = 'contains'
|
||||
g.default_sortkey = 'name'
|
||||
g.set_sort_defaults('name')
|
||||
g.set_link('name')
|
||||
|
||||
def configure_form(self, f):
|
||||
|
|
|
@ -72,8 +72,7 @@ class ScheduledShiftsView(MasterView):
|
|||
g.filters['employee'] = g.make_filter('employee', model.Person.display_name,
|
||||
default_active=True, default_verb='contains')
|
||||
|
||||
g.default_sortkey = 'start_time'
|
||||
g.default_sortdir = 'desc'
|
||||
g.set_sort_defaults('start_time', 'desc')
|
||||
|
||||
g.set_renderer('length', render_shift_length)
|
||||
|
||||
|
@ -123,8 +122,7 @@ class WorkedShiftsView(MasterView):
|
|||
# TODO: these sorters should be automatic once we fix the schema
|
||||
g.sorters['start_time'] = g.make_sorter(model.WorkedShift.punch_in)
|
||||
g.sorters['end_time'] = g.make_sorter(model.WorkedShift.punch_out)
|
||||
g.default_sortkey = 'start_time'
|
||||
g.default_sortdir = 'desc'
|
||||
g.set_sort_defaults('start_time', 'desc')
|
||||
|
||||
g.set_renderer('length', render_shift_length)
|
||||
|
||||
|
|
|
@ -72,7 +72,7 @@ class StoresView(MasterView):
|
|||
|
||||
g.set_sorter('phone', model.StorePhoneNumber.number)
|
||||
g.set_sorter('email', model.StoreEmailAddress.address)
|
||||
g.default_sortkey = 'id'
|
||||
g.set_sort_defaults('id')
|
||||
|
||||
g.set_link('id')
|
||||
g.set_link('name')
|
||||
|
|
|
@ -60,7 +60,7 @@ class SubdepartmentsView(MasterView):
|
|||
super(SubdepartmentsView, self).configure_grid(g)
|
||||
g.filters['name'].default_active = True
|
||||
g.filters['name'].default_verb = 'contains'
|
||||
g.default_sortkey = 'name'
|
||||
g.set_sort_defaults('name')
|
||||
g.set_link('number')
|
||||
g.set_link('name')
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ class TablesView(MasterView):
|
|||
def configure_grid(self, g):
|
||||
g.sorters['name'] = g.make_simple_sorter('name', foldcase=True)
|
||||
g.sorters['row_count'] = g.make_simple_sorter('row_count')
|
||||
g.default_sortkey = 'name'
|
||||
g.set_sort_defaults('name')
|
||||
|
||||
|
||||
def includeme(config):
|
||||
|
|
|
@ -50,7 +50,7 @@ class TaxesView(MasterView):
|
|||
super(TaxesView, self).configure_grid(g)
|
||||
g.filters['description'].default_active = True
|
||||
g.filters['description'].default_verb = 'contains'
|
||||
g.default_sortkey = 'code'
|
||||
g.set_sort_defaults('code')
|
||||
g.set_link('code')
|
||||
g.set_link('description')
|
||||
|
||||
|
|
|
@ -84,7 +84,7 @@ class TempmonClientView(MasterView):
|
|||
g.filters['hostname'].default_verb = 'contains'
|
||||
g.filters['location'].default_active = True
|
||||
g.filters['location'].default_verb = 'contains'
|
||||
g.default_sortkey = 'config_key'
|
||||
g.set_sort_defaults('config_key')
|
||||
|
||||
g.set_type('enabled', 'boolean')
|
||||
g.set_type('online', 'boolean')
|
||||
|
|
|
@ -70,7 +70,7 @@ class TempmonProbeView(MasterView):
|
|||
|
||||
g.joiners['client'] = lambda q: q.join(tempmon.Client)
|
||||
g.sorters['client'] = g.make_sorter(tempmon.Client.config_key)
|
||||
g.default_sortkey = 'client'
|
||||
g.set_sort_defaults('client')
|
||||
|
||||
g.set_enum('appliance_type', self.enum.TEMPMON_APPLIANCE_TYPE)
|
||||
g.set_enum('status', self.enum.TEMPMON_PROBE_STATUS)
|
||||
|
|
|
@ -74,9 +74,7 @@ class TempmonReadingView(MasterView):
|
|||
g.sorters['probe'] = g.make_sorter(tempmon.Probe.description)
|
||||
g.filters['probe'] = g.make_filter('probe', tempmon.Probe.description)
|
||||
|
||||
g.default_sortkey = 'taken'
|
||||
g.default_sortdir = 'desc'
|
||||
|
||||
g.set_sort_defaults('taken', 'desc')
|
||||
g.set_type('taken', 'datetime')
|
||||
|
||||
g.set_renderer('client_key', self.render_client_key)
|
||||
|
|
|
@ -84,8 +84,7 @@ class TransactionView(MasterView):
|
|||
g.filters['start_time'].default_active = True
|
||||
g.filters['start_time'].default_verb = 'equal'
|
||||
g.filters['start_time'].default_value = six.text_type(localtime(self.rattail_config).date())
|
||||
g.default_sortkey = 'start_time'
|
||||
g.default_sortdir = 'desc'
|
||||
g.set_sort_defaults('start_time', 'desc')
|
||||
|
||||
g.set_enum('system', self.enum.TRAINWRECK_SYSTEM)
|
||||
g.set_type('total', 'currency')
|
||||
|
@ -143,7 +142,7 @@ class TransactionView(MasterView):
|
|||
|
||||
def configure_row_grid(self, g):
|
||||
super(TransactionView, self).configure_row_grid(g)
|
||||
g.default_sortkey = 'sequence'
|
||||
g.set_sort_defaults('sequence')
|
||||
|
||||
g.set_type('unit_quantity', 'quantity')
|
||||
g.set_type('subtotal', 'currency')
|
||||
|
|
|
@ -119,8 +119,7 @@ class UpgradeView(MasterView):
|
|||
g.set_enum('status_code', self.enum.UPGRADE_STATUS)
|
||||
g.set_type('created', 'datetime')
|
||||
g.set_type('executed', 'datetime')
|
||||
g.default_sortkey = 'created'
|
||||
g.default_sortdir = 'desc'
|
||||
g.set_sort_defaults('created', 'desc')
|
||||
g.set_link('created')
|
||||
g.set_link('description')
|
||||
# g.set_link('not_until')
|
||||
|
|
|
@ -181,7 +181,7 @@ class UsersView(PrincipalMasterView):
|
|||
g.set_sorter('first_name', model.Person.first_name)
|
||||
g.set_sorter('last_name', model.Person.last_name)
|
||||
g.set_sorter('display_name', model.Person.display_name)
|
||||
g.default_sortkey = 'username'
|
||||
g.set_sort_defaults('username')
|
||||
|
||||
g.set_label('person', "Person's Name")
|
||||
|
||||
|
@ -249,8 +249,7 @@ class UsersView(PrincipalMasterView):
|
|||
super(UsersView, self).configure_row_grid(g)
|
||||
g.width = 'half'
|
||||
g.filterable = False
|
||||
g.default_sortkey = 'occurred'
|
||||
g.default_sortdir = 'desc'
|
||||
g.set_sort_defaults('occurred', 'desc')
|
||||
g.set_enum('type_code', self.enum.USER_EVENT)
|
||||
g.set_label('type_code', "Event Type")
|
||||
g.main_actions = []
|
||||
|
@ -333,8 +332,7 @@ class UserEventsView(MasterView):
|
|||
g.set_type('occurred', 'datetime')
|
||||
g.set_renderer('user', self.render_user)
|
||||
g.set_renderer('person', self.render_person)
|
||||
g.default_sortkey = 'occurred'
|
||||
g.default_sortdir = 'desc'
|
||||
g.set_sort_defaults('occurred', 'desc')
|
||||
g.set_label('user', "Username")
|
||||
g.set_label('type_code', "Event Type")
|
||||
|
||||
|
|
Loading…
Reference in a new issue