Improve columns, filters for TempMon Readings grid
This commit is contained in:
parent
fef6737832
commit
0b5a644de1
|
@ -2,7 +2,7 @@
|
|||
################################################################################
|
||||
#
|
||||
# Rattail -- Retail Software Framework
|
||||
# Copyright © 2010-2016 Lance Edgar
|
||||
# Copyright © 2010-2017 Lance Edgar
|
||||
#
|
||||
# This file is part of Rattail.
|
||||
#
|
||||
|
@ -26,8 +26,12 @@ Views for tempmon readings
|
|||
|
||||
from __future__ import unicode_literals, absolute_import
|
||||
|
||||
from sqlalchemy import orm
|
||||
|
||||
from rattail_tempmon.db import model as tempmon
|
||||
|
||||
import formalchemy as fa
|
||||
|
||||
from tailbone.views.tempmon import MasterView, ClientFieldRenderer, ProbeFieldRenderer
|
||||
|
||||
|
||||
|
@ -43,14 +47,33 @@ class TempmonReadingView(MasterView):
|
|||
creatable = False
|
||||
editable = False
|
||||
|
||||
def query(self, session):
|
||||
return session.query(tempmon.Reading)\
|
||||
.join(tempmon.Client)\
|
||||
.options(orm.joinedload(tempmon.Reading.client))
|
||||
|
||||
def _preconfigure_grid(self, g):
|
||||
|
||||
g.append(fa.Field('client_key', value=lambda r: r.client.config_key))
|
||||
g.sorters['client_key'] = g.make_sorter(tempmon.Client.config_key)
|
||||
g.filters['client_key'] = g.make_filter('client_key', tempmon.Client.config_key)
|
||||
|
||||
g.append(fa.Field('client_host', value=lambda r: r.client.hostname))
|
||||
g.sorters['client_host'] = g.make_sorter(tempmon.Client.hostname)
|
||||
g.filters['client_host'] = g.make_filter('client_host', tempmon.Client.hostname)
|
||||
|
||||
g.joiners['probe'] = lambda q: q.join(tempmon.Probe)
|
||||
g.sorters['probe'] = g.make_sorter(tempmon.Probe.description)
|
||||
g.filters['probe'] = g.make_filter('probe', tempmon.Probe.description)
|
||||
|
||||
g.default_sortkey = 'taken'
|
||||
g.default_sortdir = 'desc'
|
||||
|
||||
def configure_grid(self, g):
|
||||
g.configure(
|
||||
include=[
|
||||
g.client,
|
||||
g.client_key,
|
||||
g.client_host,
|
||||
g.probe,
|
||||
g.taken,
|
||||
g.degrees_f,
|
||||
|
|
Loading…
Reference in a new issue