Fix client field when creating / editing tempmon probe

This commit is contained in:
Lance Edgar 2018-01-15 15:21:29 -06:00
parent f9d1d34763
commit 8291c4d273

View file

@ -1,4 +1,4 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8; -*-
################################################################################ ################################################################################
# #
# Rattail -- Retail Software Framework # Rattail -- Retail Software Framework
@ -31,6 +31,7 @@ import six
from rattail_tempmon.db import model as tempmon from rattail_tempmon.db import model as tempmon
import colander import colander
from deform import widget as dfwidget
from webhelpers2.html import tags from webhelpers2.html import tags
from tailbone import forms from tailbone import forms
@ -100,6 +101,14 @@ class TempmonProbeView(MasterView):
# client # client
f.set_renderer('client', self.render_client) f.set_renderer('client', self.render_client)
f.set_label('client', "Tempmon Client") f.set_label('client', "Tempmon Client")
if self.creating or self.editing:
f.replace('client', 'client_uuid')
clients = self.Session.query(tempmon.Client)\
.order_by(tempmon.Client.config_key)
client_values = [(client.uuid, "{} ({})".format(client.config_key, client.hostname))
for client in clients]
f.set_widget('client_uuid', dfwidget.SelectWidget(values=client_values))
f.set_label('client_uuid', "Tempmon Client")
# appliance_type # appliance_type
f.set_enum('appliance_type', self.enum.TEMPMON_APPLIANCE_TYPE) f.set_enum('appliance_type', self.enum.TEMPMON_APPLIANCE_TYPE)