Tweak tempmon probe fields, make readings read-only

Still allow deletion of readings though.
This commit is contained in:
Lance Edgar 2016-11-22 12:30:21 -06:00
parent 0296c29dd7
commit 3a9930b879
2 changed files with 11 additions and 14 deletions

View file

@ -58,6 +58,7 @@ class TempmonProbeView(MasterView):
g.default_sortkey = 'client' g.default_sortkey = 'client'
g.config_key.set(label="Key") g.config_key.set(label="Key")
g.appliance_type.set(renderer=forms.renderers.EnumFieldRenderer(self.enum.TEMPMON_APPLIANCE_TYPE)) 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): def configure_grid(self, g):
g.configure( g.configure(
@ -68,12 +69,14 @@ class TempmonProbeView(MasterView):
g.description, g.description,
g.device_path, g.device_path,
g.enabled, g.enabled,
g.status,
], ],
readonly=True) readonly=True)
def _preconfigure_fieldset(self, fs): def _preconfigure_fieldset(self, fs):
fs.client.set(label="TempMon Client", renderer=ClientFieldRenderer) fs.client.set(label="TempMon Client", renderer=ClientFieldRenderer)
fs.appliance_type.set(renderer=forms.renderers.EnumFieldRenderer(self.enum.TEMPMON_APPLIANCE_TYPE)) 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): def configure_fieldset(self, fs):
fs.configure( fs.configure(
@ -83,13 +86,17 @@ class TempmonProbeView(MasterView):
fs.appliance_type, fs.appliance_type,
fs.description, fs.description,
fs.device_path, fs.device_path,
fs.critical_temp_min,
fs.good_temp_min, fs.good_temp_min,
fs.good_temp_max, fs.good_temp_max,
fs.temp_warn, fs.critical_temp_max,
fs.therm_status_timeout, fs.therm_status_timeout,
fs.alert_timeout, fs.status_alert_timeout,
fs.enabled, fs.enabled,
fs.status,
]) ])
if self.creating or self.editing:
del fs.status
def includeme(config): def includeme(config):

View file

@ -31,7 +31,6 @@ from rattail.db import model
from formalchemy.fields import SelectFieldRenderer from formalchemy.fields import SelectFieldRenderer
from webhelpers.html import tags from webhelpers.html import tags
from tailbone.db import Session
from tailbone.views import MasterView from tailbone.views import MasterView
from tailbone.views.tempmon.probes import ClientFieldRenderer from tailbone.views.tempmon.probes import ClientFieldRenderer
@ -52,6 +51,8 @@ class TempmonReadingView(MasterView):
model_class = model.TempmonReading model_class = model.TempmonReading
route_prefix = 'tempmon.readings' route_prefix = 'tempmon.readings'
url_prefix = '/tempmon/readings' url_prefix = '/tempmon/readings'
creatable = False
editable = False
def configure_grid(self, g): def configure_grid(self, g):
g.configure( g.configure(
@ -75,17 +76,6 @@ class TempmonReadingView(MasterView):
fs.taken, fs.taken,
fs.degrees_f, 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): def includeme(config):