Filter by person instead of user, for Generated Reports "Created by"
This commit is contained in:
parent
b04c1054fc
commit
cd466a64e5
|
@ -31,12 +31,9 @@ import shutil
|
|||
|
||||
import six
|
||||
|
||||
from rattail.db import model
|
||||
|
||||
from pyramid.response import FileResponse
|
||||
from webhelpers2.html import HTML, tags
|
||||
from webhelpers2.html import tags
|
||||
|
||||
from tailbone import forms
|
||||
from tailbone.views import MasterView
|
||||
|
||||
|
||||
|
@ -49,6 +46,11 @@ class ExportMasterView(MasterView):
|
|||
downloadable = False
|
||||
delete_export_files = False
|
||||
|
||||
labels = {
|
||||
'id': "ID",
|
||||
'created_by': "Created by",
|
||||
}
|
||||
|
||||
grid_columns = [
|
||||
'id',
|
||||
'created',
|
||||
|
@ -82,19 +84,23 @@ class ExportMasterView(MasterView):
|
|||
|
||||
def configure_grid(self, g):
|
||||
super(ExportMasterView, self).configure_grid(g)
|
||||
model = self.model
|
||||
|
||||
g.joiners['created_by'] = lambda q: q.join(model.User)
|
||||
g.sorters['created_by'] = g.make_sorter(model.User.username)
|
||||
g.filters['created_by'] = g.make_filter('created_by', model.User.username)
|
||||
# id
|
||||
g.set_renderer('id', self.render_id)
|
||||
g.set_link('id')
|
||||
|
||||
# filename
|
||||
g.set_link('filename')
|
||||
|
||||
# created
|
||||
g.set_sort_defaults('created', 'desc')
|
||||
|
||||
g.set_renderer('id', self.render_id)
|
||||
|
||||
g.set_label('id', "ID")
|
||||
g.set_label('created_by', "Created by")
|
||||
|
||||
g.set_link('id')
|
||||
g.set_link('filename')
|
||||
# created_by
|
||||
g.set_joiner('created_by',
|
||||
lambda q: q.join(model.User).outerjoin(model.Person))
|
||||
g.set_sorter('created_by', model.Person.display_name)
|
||||
g.set_filter('created_by', model.Person.display_name)
|
||||
|
||||
def render_id(self, export, field):
|
||||
return export.id_str
|
||||
|
|
Loading…
Reference in a new issue