Add new "v3" grids, refactor all views to use them
or at least that's the idea..hopefully we caught them all
This commit is contained in:
parent
f244c2934b
commit
5b1ae27a10
71 changed files with 2679 additions and 2030 deletions
|
@ -32,9 +32,9 @@ from rattail.db import model
|
|||
|
||||
import formalchemy as fa
|
||||
|
||||
from tailbone import forms, newgrids as grids
|
||||
from tailbone import forms, grids3 as grids
|
||||
from tailbone.db import Session
|
||||
from tailbone.views import MasterView, AutocompleteView
|
||||
from tailbone.views import MasterView2 as MasterView, AutocompleteView
|
||||
|
||||
|
||||
class EmployeesView(MasterView):
|
||||
|
@ -44,7 +44,18 @@ class EmployeesView(MasterView):
|
|||
model_class = model.Employee
|
||||
has_versions = True
|
||||
|
||||
def _preconfigure_grid(self, g):
|
||||
grid_columns = [
|
||||
'id',
|
||||
'first_name',
|
||||
'last_name',
|
||||
'phone',
|
||||
'email',
|
||||
'status',
|
||||
]
|
||||
|
||||
def configure_grid(self, g):
|
||||
super(EmployeesView, self).configure_grid(g)
|
||||
|
||||
g.joiners['phone'] = lambda q: q.outerjoin(model.EmployeePhoneNumber, sa.and_(
|
||||
model.EmployeePhoneNumber.parent_uuid == model.Employee.uuid,
|
||||
model.EmployeePhoneNumber.preference == 1))
|
||||
|
@ -61,7 +72,6 @@ class EmployeesView(MasterView):
|
|||
label="Phone Number")
|
||||
|
||||
if self.request.has_perm('employees.edit'):
|
||||
g.filters['id'].label = "ID"
|
||||
g.filters['status'].default_active = True
|
||||
g.filters['status'].default_verb = 'equal'
|
||||
g.filters['status'].default_value = self.enum.EMPLOYEE_STATUS_CURRENT
|
||||
|
@ -84,25 +94,15 @@ class EmployeesView(MasterView):
|
|||
|
||||
g.default_sortkey = 'first_name'
|
||||
|
||||
g.append(forms.AssociationProxyField('first_name'))
|
||||
g.append(forms.AssociationProxyField('last_name'))
|
||||
g.set_enum('status', self.enum.EMPLOYEE_STATUS)
|
||||
|
||||
def configure_grid(self, g):
|
||||
|
||||
g.configure(
|
||||
include=[
|
||||
g.id.label("ID"),
|
||||
g.first_name,
|
||||
g.last_name,
|
||||
g.phone.label("Phone Number"),
|
||||
g.email.label("Email Address"),
|
||||
g.status.with_renderer(forms.renderers.EnumFieldRenderer(self.enum.EMPLOYEE_STATUS)),
|
||||
],
|
||||
readonly=True)
|
||||
g.set_label('id', "ID")
|
||||
g.set_label('phone', "Phone Number")
|
||||
g.set_label('email', "Email Address")
|
||||
|
||||
if not self.request.has_perm('employees.edit'):
|
||||
del g.id
|
||||
del g.status
|
||||
g.hide_column('id')
|
||||
g.hide_column('status')
|
||||
|
||||
def query(self, session):
|
||||
q = session.query(model.Employee).join(model.Person)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue