Add probe URL to email template context

This commit is contained in:
Lance Edgar 2018-10-17 18:08:54 -05:00
parent d6ab9a60f1
commit 71db57b2e0
2 changed files with 6 additions and 1 deletions

View file

@ -2,7 +2,7 @@
################################################################################ ################################################################################
# #
# Rattail -- Retail Software Framework # Rattail -- Retail Software Framework
# Copyright © 2010-2017 Lance Edgar # Copyright © 2010-2018 Lance Edgar
# #
# This file is part of Rattail. # This file is part of Rattail.
# #
@ -50,6 +50,7 @@ class TempmonBase(object):
'reading': model.TempmonReading(), 'reading': model.TempmonReading(),
'taken': now, 'taken': now,
'now': now, 'now': now,
'probe_url': '#',
} }

View file

@ -221,6 +221,10 @@ class TempmonServerDaemon(Daemon):
if (self.now - probe.status_changed) <= timeout: if (self.now - probe.status_changed) <= timeout:
return return
# determine URL for probe, if possible
url = self.config.get('tailbone', 'url.tempmon.probe', default='#')
data['probe_url'] = url.format(uuid=probe.uuid)
since = localtime(self.config, probe.status_changed, from_utc=True) since = localtime(self.config, probe.status_changed, from_utc=True)
data['status_since'] = since.strftime('%I:%M %p') data['status_since'] = since.strftime('%I:%M %p')
data['status_since_delta'] = humanize.naturaltime(self.now - probe.status_changed) data['status_since_delta'] = humanize.naturaltime(self.now - probe.status_changed)