-
General
-
-
- ${self.render_main_fields(form)}
+
+
+
+
General
+
+
+ ${self.render_main_fields(form)}
+
+
-## % if image_url:
-## ${h.image(image_url, "Probe Image", id='probe-image', width=150, height=150)}
-## % endif
+
+
+
+ ${self.left_column()}
+
+
+ ${self.right_column()}
+
+
+
-
- ${self.left_column()}
-
-
-
- ${self.right_column()}
-
+
diff --git a/tailbone/views/tempmon/clients.py b/tailbone/views/tempmon/clients.py
index d38d38f2..f455d0f8 100644
--- a/tailbone/views/tempmon/clients.py
+++ b/tailbone/views/tempmon/clients.py
@@ -2,7 +2,7 @@
################################################################################
#
# Rattail -- Retail Software Framework
-# Copyright © 2010-2018 Lance Edgar
+# Copyright © 2010-2019 Lance Edgar
#
# This file is part of Rattail.
#
@@ -34,6 +34,7 @@ from rattail_tempmon.db import model as tempmon
import colander
from webhelpers2.html import HTML, tags
+from tailbone import forms
from tailbone.views.tempmon import MasterView
@@ -101,6 +102,9 @@ class TempmonClientView(MasterView):
# disk_type
g.set_enum('disk_type', self.enum.TEMPMON_DISK_TYPE)
+ # enabled
+ g.set_type('enabled', 'boolean')
+
# archived
g.filters['archived'].default_active = True
g.filters['archived'].default_verb = 'is_false'
@@ -134,6 +138,8 @@ class TempmonClientView(MasterView):
f.set_type('notes', 'text')
# enabled
+ if self.creating or self.editing:
+ f.set_node('enabled', forms.types.DateTimeBoolean())
f.set_helptext('enabled', tempmon.Client.enabled.__doc__)
# online
@@ -145,6 +151,18 @@ class TempmonClientView(MasterView):
# archived
f.set_helptext('archived', tempmon.Client.archived.__doc__)
+ def objectify(self, form, data=None):
+
+ # this is a hack to prevent updates to the 'enabled' timestamp, when
+ # simple edits are being done to the client. i.e. we do want to set
+ # the timestamp when it was previously null, but not otherwise.
+ if self.editing:
+ data = dict(data or form.validated)
+ if data['enabled'] and form.model_instance.enabled:
+ data['enabled'] = form.model_instance.enabled
+
+ return super(TempmonClientView, self).objectify(form, data=data)
+
def unique_config_key(self, node, value):
query = self.Session.query(tempmon.Client)\
.filter(tempmon.Client.config_key == value)
diff --git a/tailbone/views/tempmon/probes.py b/tailbone/views/tempmon/probes.py
index 479d6c31..1e81f56f 100644
--- a/tailbone/views/tempmon/probes.py
+++ b/tailbone/views/tempmon/probes.py
@@ -37,7 +37,7 @@ import colander
from deform import widget as dfwidget
from webhelpers2.html import tags
-from tailbone import grids
+from tailbone import forms, grids
from tailbone.views.tempmon import MasterView
@@ -168,6 +168,23 @@ class TempmonProbeView(MasterView):
if self.creating or self.editing:
f.remove_fields('status')
+ # enabled
+ if self.creating or self.editing:
+ f.set_node('enabled', forms.types.DateTimeBoolean())
+ f.set_helptext('enabled', tempmon.Probe.enabled.__doc__)
+
+ def objectify(self, form, data=None):
+
+ # this is a hack to prevent updates to the 'enabled' timestamp, when
+ # simple edits are being done to the probe. i.e. we do want to set the
+ # timestamp when it was previously null, but not otherwise.
+ if self.editing:
+ data = dict(data or form.validated)
+ if data['enabled'] and form.model_instance.enabled:
+ data['enabled'] = form.model_instance.enabled
+
+ return super(TempmonProbeView, self).objectify(form, data=data)
+
def unique_config_key(self, node, value):
query = self.Session.query(tempmon.Probe)\
.filter(tempmon.Probe.config_key == value)