Add "status since" to template context for email alerts
This commit is contained in:
parent
76e40063ee
commit
b4fa6a17c5
|
@ -1,8 +1,8 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# -*- coding: utf-8; -*-
|
||||
################################################################################
|
||||
#
|
||||
# Rattail -- Retail Software Framework
|
||||
# Copyright © 2010-2017 Lance Edgar
|
||||
# Copyright © 2010-2018 Lance Edgar
|
||||
#
|
||||
# This file is part of Rattail.
|
||||
#
|
||||
|
@ -30,6 +30,8 @@ import time
|
|||
import datetime
|
||||
import logging
|
||||
|
||||
import humanize
|
||||
|
||||
from rattail.db import Session, api
|
||||
from rattail_tempmon.db import Session as TempmonSession, model as tempmon
|
||||
from rattail.daemon import Daemon
|
||||
|
@ -183,6 +185,10 @@ class TempmonServerDaemon(Daemon):
|
|||
if (self.now - probe.status_changed) <= timeout:
|
||||
return
|
||||
|
||||
since = localtime(self.config, probe.status_changed, from_utc=True)
|
||||
data['status_since'] = since.strftime('%I:%M %p')
|
||||
data['status_since_delta'] = humanize.naturaltime(self.now - probe.status_changed)
|
||||
|
||||
msgtypes = {
|
||||
self.enum.TEMPMON_PROBE_STATUS_LOW_TEMP : 'tempmon_low_temp',
|
||||
self.enum.TEMPMON_PROBE_STATUS_HIGH_TEMP : 'tempmon_high_temp',
|
||||
|
|
Loading…
Reference in a new issue