Cleanup attribute names for CORE Department model

This commit is contained in:
Lance Edgar 2019-07-23 19:45:29 -05:00
parent baa4ff4ba4
commit 7cad813480
4 changed files with 27 additions and 32 deletions

View file

@ -84,8 +84,8 @@ class HouseCouponView(CoreOfficeMasterView):
g.set_renderer('end_date', self.render_local_date) g.set_renderer('end_date', self.render_local_date)
g.set_joiner('department', lambda q: q.outerjoin(corepos.Department)) g.set_joiner('department', lambda q: q.outerjoin(corepos.Department))
g.set_filter('department', corepos.Department.dept_name, label="Department Name") g.set_filter('department', corepos.Department.name, label="Department Name")
g.set_sorter('department', corepos.Department.dept_name) g.set_sorter('department', corepos.Department.name)
g.set_sort_defaults('coupon_id', 'desc') g.set_sort_defaults('coupon_id', 'desc')

View file

@ -39,50 +39,45 @@ class DepartmentView(CoreOfficeMasterView):
route_prefix = 'corepos.departments' route_prefix = 'corepos.departments'
labels = { 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", 'dept_see_id': "See ID",
'modifiedby': "Modified by", 'modified_by_id': "Modified by ID",
'salesCode': "Sales Code",
'memberOnly': "Member Only",
} }
grid_columns = [ grid_columns = [
'dept_no', 'number',
'dept_name', 'name',
'dept_tax', 'tax',
'dept_fs', 'food_stampable',
'dept_limit', 'limit',
'dept_minimum', 'minimum',
'dept_discount', 'discount',
'dept_see_id', 'dept_see_id',
'modified', 'modified',
'modifiedby', 'modified_by_id',
'margin', 'margin',
'salesCode', 'sales_code',
'memberOnly', 'member_only',
] ]
def configure_grid(self, g): def configure_grid(self, g):
super(DepartmentView, self).configure_grid(g) super(DepartmentView, self).configure_grid(g)
g.filters['dept_no'].default_active = True g.filters['number'].default_active = True
g.filters['dept_no'].default_verb = 'equal' g.filters['number'].default_verb = 'equal'
g.filters['dept_name'].default_active = True g.filters['name'].default_active = True
g.filters['dept_name'].default_verb = 'contains' 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_type('modified', 'datetime_local')
g.set_sort_defaults('dept_no') g.set_sort_defaults('number')
g.set_link('dept_no') g.set_link('number')
g.set_link('dept_name') g.set_link('name')
def includeme(config): def includeme(config):

View file

@ -92,8 +92,8 @@ class CoreOfficeMasterView(MasterView):
department = getattr(obj, field) department = getattr(obj, field)
if not department: if not department:
return "" return ""
text = "({}) {}".format(department.dept_no, department.dept_name) text = "({}) {}".format(department.number, department.name)
url = self.request.route_url('corepos.departments.view', dept_no=department.dept_no) url = self.request.route_url('corepos.departments.view', number=department.number)
return tags.link_to(text, url) return tags.link_to(text, url)
def render_corepos_vendor(self, obj, field): def render_corepos_vendor(self, obj, field):

View file

@ -79,7 +79,7 @@ class ProductView(CoreOfficeMasterView):
super(ProductView, self).configure_grid(g) super(ProductView, self).configure_grid(g)
g.set_joiner('department', lambda q: q.outerjoin(corepos.Department)) 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, g.set_joiner('vendor', lambda q: q.outerjoin(corepos.Vendor,
corepos.Vendor.id == corepos.Product.default_vendor_id)) corepos.Vendor.id == corepos.Product.default_vendor_id))