Cleanup 'phone' filter/sort logic for Employees grid
per newer conventions etc. needed to override some of this for a client
This commit is contained in:
parent
e756ae3c8f
commit
6e1f925944
|
@ -49,6 +49,7 @@ class EmployeesView(MasterView):
|
|||
|
||||
labels = {
|
||||
'id': "ID",
|
||||
'phone': "Phone Number",
|
||||
}
|
||||
|
||||
grid_columns = [
|
||||
|
@ -79,9 +80,15 @@ class EmployeesView(MasterView):
|
|||
super(EmployeesView, self).configure_grid(g)
|
||||
route_prefix = self.get_route_prefix()
|
||||
|
||||
g.joiners['phone'] = lambda q: q.outerjoin(model.EmployeePhoneNumber, sa.and_(
|
||||
# phone
|
||||
g.set_joiner('phone', lambda q: q.outerjoin(model.EmployeePhoneNumber, sa.and_(
|
||||
model.EmployeePhoneNumber.parent_uuid == model.Employee.uuid,
|
||||
model.EmployeePhoneNumber.preference == 1))
|
||||
model.EmployeePhoneNumber.preference == 1)))
|
||||
g.set_filter('phone', model.EmployeePhoneNumber.number,
|
||||
label="Phone Number",
|
||||
factory=grids.filters.AlchemyPhoneNumberFilter)
|
||||
g.set_sorter('phone', model.EmployeePhoneNumber.number)
|
||||
|
||||
g.joiners['email'] = lambda q: q.outerjoin(model.EmployeeEmailAddress, sa.and_(
|
||||
model.EmployeeEmailAddress.parent_uuid == model.Employee.uuid,
|
||||
model.EmployeeEmailAddress.preference == 1))
|
||||
|
@ -91,9 +98,6 @@ class EmployeesView(MasterView):
|
|||
|
||||
g.filters['email'] = g.make_filter('email', model.EmployeeEmailAddress.address,
|
||||
label="Email Address")
|
||||
g.set_filter('phone', model.EmployeePhoneNumber.number,
|
||||
label="Phone Number",
|
||||
factory=grids.filters.AlchemyPhoneNumberFilter)
|
||||
|
||||
# id
|
||||
if self.request.has_perm('{}.edit'.format(route_prefix)):
|
||||
|
@ -123,11 +127,9 @@ class EmployeesView(MasterView):
|
|||
g.sorters['last_name'] = lambda q, d: q.order_by(getattr(model.Person.last_name, d)())
|
||||
|
||||
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.set_sort_defaults('first_name')
|
||||
|
||||
g.set_label('phone', "Phone Number")
|
||||
g.set_label('email', "Email Address")
|
||||
|
||||
g.set_link('first_name')
|
||||
|
@ -191,7 +193,6 @@ class EmployeesView(MasterView):
|
|||
f.set_readonly('email')
|
||||
|
||||
f.set_label('display_name', "Short Name")
|
||||
f.set_label('phone', "Phone Number")
|
||||
f.set_label('email', "Email Address")
|
||||
|
||||
if not self.viewing:
|
||||
|
|
Loading…
Reference in a new issue