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_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')

View file

@ -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):

View file

@ -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):

View file

@ -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))