Tweak tempmon probe fields, make readings read-only
Still allow deletion of readings though.
This commit is contained in:
parent
0296c29dd7
commit
3a9930b879
|
@ -58,6 +58,7 @@ class TempmonProbeView(MasterView):
|
|||
g.default_sortkey = 'client'
|
||||
g.config_key.set(label="Key")
|
||||
g.appliance_type.set(renderer=forms.renderers.EnumFieldRenderer(self.enum.TEMPMON_APPLIANCE_TYPE))
|
||||
g.status.set(renderer=forms.renderers.EnumFieldRenderer(self.enum.TEMPMON_PROBE_STATUS))
|
||||
|
||||
def configure_grid(self, g):
|
||||
g.configure(
|
||||
|
@ -68,12 +69,14 @@ class TempmonProbeView(MasterView):
|
|||
g.description,
|
||||
g.device_path,
|
||||
g.enabled,
|
||||
g.status,
|
||||
],
|
||||
readonly=True)
|
||||
|
||||
def _preconfigure_fieldset(self, fs):
|
||||
fs.client.set(label="TempMon Client", renderer=ClientFieldRenderer)
|
||||
fs.appliance_type.set(renderer=forms.renderers.EnumFieldRenderer(self.enum.TEMPMON_APPLIANCE_TYPE))
|
||||
fs.status.set(renderer=forms.renderers.EnumFieldRenderer(self.enum.TEMPMON_PROBE_STATUS))
|
||||
|
||||
def configure_fieldset(self, fs):
|
||||
fs.configure(
|
||||
|
@ -83,13 +86,17 @@ class TempmonProbeView(MasterView):
|
|||
fs.appliance_type,
|
||||
fs.description,
|
||||
fs.device_path,
|
||||
fs.critical_temp_min,
|
||||
fs.good_temp_min,
|
||||
fs.good_temp_max,
|
||||
fs.temp_warn,
|
||||
fs.critical_temp_max,
|
||||
fs.therm_status_timeout,
|
||||
fs.alert_timeout,
|
||||
fs.status_alert_timeout,
|
||||
fs.enabled,
|
||||
fs.status,
|
||||
])
|
||||
if self.creating or self.editing:
|
||||
del fs.status
|
||||
|
||||
|
||||
def includeme(config):
|
||||
|
|
|
@ -31,7 +31,6 @@ from rattail.db import model
|
|||
from formalchemy.fields import SelectFieldRenderer
|
||||
from webhelpers.html import tags
|
||||
|
||||
from tailbone.db import Session
|
||||
from tailbone.views import MasterView
|
||||
from tailbone.views.tempmon.probes import ClientFieldRenderer
|
||||
|
||||
|
@ -52,6 +51,8 @@ class TempmonReadingView(MasterView):
|
|||
model_class = model.TempmonReading
|
||||
route_prefix = 'tempmon.readings'
|
||||
url_prefix = '/tempmon/readings'
|
||||
creatable = False
|
||||
editable = False
|
||||
|
||||
def configure_grid(self, g):
|
||||
g.configure(
|
||||
|
@ -75,17 +76,6 @@ class TempmonReadingView(MasterView):
|
|||
fs.taken,
|
||||
fs.degrees_f,
|
||||
])
|
||||
if self.creating:
|
||||
del fs.taken
|
||||
|
||||
# TODO: this should not be so complicated....
|
||||
def save_create_form(self, form):
|
||||
with Session.no_autoflush:
|
||||
form.fieldset.sync()
|
||||
reading = form.fieldset.model
|
||||
probe = Session.query(model.TempmonProbe).get(reading.probe_uuid)
|
||||
reading.client = probe.client
|
||||
Session.flush()
|
||||
|
||||
|
||||
def includeme(config):
|
||||
|
|
Loading…
Reference in a new issue