From 7cad813480c533a3350120d5c077482bf69debb3 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Tue, 23 Jul 2019 19:45:29 -0500 Subject: [PATCH] Cleanup attribute names for CORE Department model --- tailbone_corepos/views/corepos/coupons.py | 4 +- tailbone_corepos/views/corepos/departments.py | 49 +++++++++---------- tailbone_corepos/views/corepos/master.py | 4 +- tailbone_corepos/views/corepos/products.py | 2 +- 4 files changed, 27 insertions(+), 32 deletions(-) diff --git a/tailbone_corepos/views/corepos/coupons.py b/tailbone_corepos/views/corepos/coupons.py index e37cb9a..02aa2e0 100644 --- a/tailbone_corepos/views/corepos/coupons.py +++ b/tailbone_corepos/views/corepos/coupons.py @@ -84,8 +84,8 @@ class HouseCouponView(CoreOfficeMasterView): g.set_renderer('end_date', self.render_local_date) g.set_joiner('department', lambda q: q.outerjoin(corepos.Department)) - g.set_filter('department', corepos.Department.dept_name, label="Department Name") - g.set_sorter('department', corepos.Department.dept_name) + g.set_filter('department', corepos.Department.name, label="Department Name") + g.set_sorter('department', corepos.Department.name) g.set_sort_defaults('coupon_id', 'desc') diff --git a/tailbone_corepos/views/corepos/departments.py b/tailbone_corepos/views/corepos/departments.py index 7f55da7..3a83d29 100644 --- a/tailbone_corepos/views/corepos/departments.py +++ b/tailbone_corepos/views/corepos/departments.py @@ -39,50 +39,45 @@ class DepartmentView(CoreOfficeMasterView): route_prefix = 'corepos.departments' labels = { - 'dept_no': "Number", - 'dept_name': "Name", - 'dept_tax': "Tax", - 'dept_fs': "FS", - 'dept_limit': "Limit", - 'dept_minimum': "Minimum", - 'dept_discount': "Discount", 'dept_see_id': "See ID", - 'modifiedby': "Modified by", - 'salesCode': "Sales Code", - 'memberOnly': "Member Only", + 'modified_by_id': "Modified by ID", } grid_columns = [ - 'dept_no', - 'dept_name', - 'dept_tax', - 'dept_fs', - 'dept_limit', - 'dept_minimum', - 'dept_discount', + 'number', + 'name', + 'tax', + 'food_stampable', + 'limit', + 'minimum', + 'discount', 'dept_see_id', 'modified', - 'modifiedby', + 'modified_by_id', 'margin', - 'salesCode', - 'memberOnly', + 'sales_code', + 'member_only', ] def configure_grid(self, g): super(DepartmentView, self).configure_grid(g) - g.filters['dept_no'].default_active = True - g.filters['dept_no'].default_verb = 'equal' + g.filters['number'].default_active = True + g.filters['number'].default_verb = 'equal' - g.filters['dept_name'].default_active = True - g.filters['dept_name'].default_verb = 'contains' + g.filters['name'].default_active = True + g.filters['name'].default_verb = 'contains' + + # TODO: it should be easier to set only grid header label + g.set_label('food_stampable', "FS") + g.filters['food_stampable'].label = "Food Stampable" g.set_type('modified', 'datetime_local') - g.set_sort_defaults('dept_no') + g.set_sort_defaults('number') - g.set_link('dept_no') - g.set_link('dept_name') + g.set_link('number') + g.set_link('name') def includeme(config): diff --git a/tailbone_corepos/views/corepos/master.py b/tailbone_corepos/views/corepos/master.py index faede1a..ff95e35 100644 --- a/tailbone_corepos/views/corepos/master.py +++ b/tailbone_corepos/views/corepos/master.py @@ -92,8 +92,8 @@ class CoreOfficeMasterView(MasterView): department = getattr(obj, field) if not department: return "" - text = "({}) {}".format(department.dept_no, department.dept_name) - url = self.request.route_url('corepos.departments.view', dept_no=department.dept_no) + text = "({}) {}".format(department.number, department.name) + url = self.request.route_url('corepos.departments.view', number=department.number) return tags.link_to(text, url) def render_corepos_vendor(self, obj, field): diff --git a/tailbone_corepos/views/corepos/products.py b/tailbone_corepos/views/corepos/products.py index c86fcfc..6d6b87d 100644 --- a/tailbone_corepos/views/corepos/products.py +++ b/tailbone_corepos/views/corepos/products.py @@ -79,7 +79,7 @@ class ProductView(CoreOfficeMasterView): super(ProductView, self).configure_grid(g) g.set_joiner('department', lambda q: q.outerjoin(corepos.Department)) - g.set_sorter('department', corepos.Department.dept_name) + g.set_sorter('department', corepos.Department.name) g.set_joiner('vendor', lambda q: q.outerjoin(corepos.Vendor, corepos.Vendor.id == corepos.Product.default_vendor_id))