Update tempmon UI now that enabled
flags are really datetime in DB
This commit is contained in:
parent
90e1baef50
commit
eb78d79bb3
|
@ -2,7 +2,7 @@
|
||||||
################################################################################
|
################################################################################
|
||||||
#
|
#
|
||||||
# Rattail -- Retail Software Framework
|
# Rattail -- Retail Software Framework
|
||||||
# Copyright © 2010-2018 Lance Edgar
|
# Copyright © 2010-2019 Lance Edgar
|
||||||
#
|
#
|
||||||
# This file is part of Rattail.
|
# This file is part of Rattail.
|
||||||
#
|
#
|
||||||
|
@ -27,6 +27,7 @@ Form Schema Types
|
||||||
from __future__ import unicode_literals, absolute_import
|
from __future__ import unicode_literals, absolute_import
|
||||||
|
|
||||||
import re
|
import re
|
||||||
|
import datetime
|
||||||
|
|
||||||
import six
|
import six
|
||||||
|
|
||||||
|
@ -63,6 +64,18 @@ class JQueryTime(colander.Time):
|
||||||
return colander.timeparse(cstruct, formats[0])
|
return colander.timeparse(cstruct, formats[0])
|
||||||
|
|
||||||
|
|
||||||
|
class DateTimeBoolean(colander.Boolean):
|
||||||
|
"""
|
||||||
|
Schema type which presents the user with a "boolean" whereas the underlying
|
||||||
|
node is really a datetime (assumed to be "naive" UTC, and allow nulls).
|
||||||
|
"""
|
||||||
|
|
||||||
|
def deserialize(self, node, cstruct):
|
||||||
|
value = super(DateTimeBoolean, self).deserialize(node, cstruct)
|
||||||
|
if value: # else return None
|
||||||
|
return datetime.datetime.utcnow()
|
||||||
|
|
||||||
|
|
||||||
class GPCType(colander.SchemaType):
|
class GPCType(colander.SchemaType):
|
||||||
"""
|
"""
|
||||||
Schema type for product GPC data.
|
Schema type for product GPC data.
|
||||||
|
|
|
@ -5,31 +5,36 @@
|
||||||
## page body
|
## page body
|
||||||
##############################
|
##############################
|
||||||
|
|
||||||
<ul id="context-menu">
|
<div style="display: flex; justify-content: space-between;">
|
||||||
${self.context_menu_items()}
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<div class="form-wrapper">
|
<div class="form-wrapper">
|
||||||
|
|
||||||
<div class="panel" id="probe-main">
|
<div style="display: flex; flex-direction: column;">
|
||||||
<h2>General</h2>
|
|
||||||
<div class="panel-body">
|
<div class="panel" id="probe-main">
|
||||||
<div style="clear: none; float: left;">
|
<h2>General</h2>
|
||||||
${self.render_main_fields(form)}
|
<div class="panel-body">
|
||||||
|
<div>
|
||||||
|
${self.render_main_fields(form)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
## % if image_url:
|
|
||||||
## ${h.image(image_url, "Probe Image", id='probe-image', width=150, height=150)}
|
<div style="display: flex;">
|
||||||
## % endif
|
<div class="panel-wrapper">
|
||||||
|
${self.left_column()}
|
||||||
|
</div>
|
||||||
|
<div class="panel-wrapper" style="margin-left: 1em;"> <!-- right column -->
|
||||||
|
${self.right_column()}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="panel-wrapper">
|
<ul id="context-menu">
|
||||||
${self.left_column()}
|
${self.context_menu_items()}
|
||||||
</div>
|
</ul>
|
||||||
|
|
||||||
<div class="panel-wrapper">
|
|
||||||
${self.right_column()}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
################################################################################
|
################################################################################
|
||||||
#
|
#
|
||||||
# Rattail -- Retail Software Framework
|
# Rattail -- Retail Software Framework
|
||||||
# Copyright © 2010-2018 Lance Edgar
|
# Copyright © 2010-2019 Lance Edgar
|
||||||
#
|
#
|
||||||
# This file is part of Rattail.
|
# This file is part of Rattail.
|
||||||
#
|
#
|
||||||
|
@ -34,6 +34,7 @@ from rattail_tempmon.db import model as tempmon
|
||||||
import colander
|
import colander
|
||||||
from webhelpers2.html import HTML, tags
|
from webhelpers2.html import HTML, tags
|
||||||
|
|
||||||
|
from tailbone import forms
|
||||||
from tailbone.views.tempmon import MasterView
|
from tailbone.views.tempmon import MasterView
|
||||||
|
|
||||||
|
|
||||||
|
@ -101,6 +102,9 @@ class TempmonClientView(MasterView):
|
||||||
# disk_type
|
# disk_type
|
||||||
g.set_enum('disk_type', self.enum.TEMPMON_DISK_TYPE)
|
g.set_enum('disk_type', self.enum.TEMPMON_DISK_TYPE)
|
||||||
|
|
||||||
|
# enabled
|
||||||
|
g.set_type('enabled', 'boolean')
|
||||||
|
|
||||||
# archived
|
# archived
|
||||||
g.filters['archived'].default_active = True
|
g.filters['archived'].default_active = True
|
||||||
g.filters['archived'].default_verb = 'is_false'
|
g.filters['archived'].default_verb = 'is_false'
|
||||||
|
@ -134,6 +138,8 @@ class TempmonClientView(MasterView):
|
||||||
f.set_type('notes', 'text')
|
f.set_type('notes', 'text')
|
||||||
|
|
||||||
# enabled
|
# enabled
|
||||||
|
if self.creating or self.editing:
|
||||||
|
f.set_node('enabled', forms.types.DateTimeBoolean())
|
||||||
f.set_helptext('enabled', tempmon.Client.enabled.__doc__)
|
f.set_helptext('enabled', tempmon.Client.enabled.__doc__)
|
||||||
|
|
||||||
# online
|
# online
|
||||||
|
@ -145,6 +151,18 @@ class TempmonClientView(MasterView):
|
||||||
# archived
|
# archived
|
||||||
f.set_helptext('archived', tempmon.Client.archived.__doc__)
|
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):
|
def unique_config_key(self, node, value):
|
||||||
query = self.Session.query(tempmon.Client)\
|
query = self.Session.query(tempmon.Client)\
|
||||||
.filter(tempmon.Client.config_key == value)
|
.filter(tempmon.Client.config_key == value)
|
||||||
|
|
|
@ -37,7 +37,7 @@ import colander
|
||||||
from deform import widget as dfwidget
|
from deform import widget as dfwidget
|
||||||
from webhelpers2.html import tags
|
from webhelpers2.html import tags
|
||||||
|
|
||||||
from tailbone import grids
|
from tailbone import forms, grids
|
||||||
from tailbone.views.tempmon import MasterView
|
from tailbone.views.tempmon import MasterView
|
||||||
|
|
||||||
|
|
||||||
|
@ -168,6 +168,23 @@ class TempmonProbeView(MasterView):
|
||||||
if self.creating or self.editing:
|
if self.creating or self.editing:
|
||||||
f.remove_fields('status')
|
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):
|
def unique_config_key(self, node, value):
|
||||||
query = self.Session.query(tempmon.Probe)\
|
query = self.Session.query(tempmon.Probe)\
|
||||||
.filter(tempmon.Probe.config_key == value)
|
.filter(tempmon.Probe.config_key == value)
|
||||||
|
|
Loading…
Reference in a new issue