Add basic master view for PersonNote data model
This commit is contained in:
parent
f61cf318ae
commit
e6301f0d06
|
@ -28,6 +28,7 @@ from __future__ import unicode_literals, absolute_import
|
|||
|
||||
import six
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy import orm
|
||||
|
||||
from rattail.db import model, api
|
||||
|
||||
|
@ -305,6 +306,60 @@ class PeopleEmployeesAutocomplete(PeopleAutocomplete):
|
|||
return q.join(model.Employee)
|
||||
|
||||
|
||||
class PersonNoteView(MasterView):
|
||||
"""
|
||||
Master view for the PersonNote class.
|
||||
"""
|
||||
model_class = model.PersonNote
|
||||
route_prefix = 'person_notes'
|
||||
url_prefix = '/people/notes'
|
||||
has_versions = True
|
||||
|
||||
grid_columns = [
|
||||
'person',
|
||||
'type',
|
||||
'subject',
|
||||
'created',
|
||||
'created_by',
|
||||
]
|
||||
|
||||
form_fields = [
|
||||
'person',
|
||||
'type',
|
||||
'subject',
|
||||
'text',
|
||||
'created',
|
||||
'created_by',
|
||||
]
|
||||
|
||||
def get_instance_title(self, note):
|
||||
return note.subject or "(no subject)"
|
||||
|
||||
def configure_grid(self, g):
|
||||
super(PersonNoteView, self).configure_grid(g)
|
||||
|
||||
# person
|
||||
g.set_joiner('person', lambda q: q.join(model.Person,
|
||||
model.Person.uuid == model.PersonNote.parent_uuid))
|
||||
g.set_sorter('person', model.Person.display_name)
|
||||
g.set_filter('person', model.Person.display_name, label="Person Name")
|
||||
|
||||
# created_by
|
||||
CreatorPerson = orm.aliased(model.Person)
|
||||
g.set_joiner('created_by', lambda q: q.join(model.User).outerjoin(CreatorPerson,
|
||||
CreatorPerson.uuid == model.User.person_uuid))
|
||||
g.set_sorter('created_by', CreatorPerson.display_name)
|
||||
|
||||
g.set_link('person')
|
||||
g.set_link('subject')
|
||||
g.set_link('created')
|
||||
|
||||
def configure_form(self, f):
|
||||
super(PersonNoteView, self).configure_form(f)
|
||||
|
||||
f.set_renderer('person', self.render_person)
|
||||
|
||||
|
||||
def includeme(config):
|
||||
|
||||
# autocomplete
|
||||
|
@ -316,3 +371,4 @@ def includeme(config):
|
|||
renderer='json', permission='people.list')
|
||||
|
||||
PeopleView.defaults(config)
|
||||
PersonNoteView.defaults(config)
|
||||
|
|
Loading…
Reference in a new issue