Commit 734007b7 authored by Rafael Monnerat's avatar Rafael Monnerat 👻

erp5_administration: Indicate Alarm errors via RSS

   PoC inclusion of Alarm errors on ERP5. So you don't need to rely on email notification to know some alarm has execution error.

   For now it just browse all enabled (using alarm_date not None), but in future, we could include a more narrow scope.
parent 2d814f2a
from Products.ERP5Type.Document import newTempBase
from Products.ZSQLCatalog.SQLCatalog import Query, NegatedQuery
from DateTime import DateTime
from zExceptions import Unauthorized
if REQUEST is not None:
raise Unauthorized
portal = context.getPortalObject()
# Use only the first entry. This prevents change the rss content
# too often whenever multiple activities are failing over time.
message_list = portal.portal_activities.getMessageTempObjectList(processing_node=-2,
count=1)
if not len(message_list):
return []
message = portal.Base_translateString('You have one or more activity failures.')
# Make compatible with renderjs_runner
web_site = context.getWebSiteValue()
if web_site is None:
web_site_url = portal.absolute_url()
else:
web_site_url = web_site.absolute_url() + "/#"
return [
newTempBase(portal, "rss_entry",
uid=message_list[0].uid,
date=DateTime().earliestTime(),
link="%s/portal_activities" % web_site_url,
title=message)]
pending_error_message_list = []
# Use only the first entry. This prevents change the rss content
# too often whenever multiple activities are failing over time.
message_list = portal.portal_activities.getMessageTempObjectList(
processing_node=-2, count=1)
if len(message_list):
message = portal.Base_translateString('You have one or more activity failures.')
pending_error_message_list.append(
newTempBase(portal, "rss_entry",
uid=message_list[0].uid,
date=DateTime().earliestTime(),
link="%s/portal_activities" % web_site_url,
title=message))
alarm_list = portal.portal_catalog(
portal_type=portal.getPortalAlarmTypeList(),
alarm_date=NegatedQuery(Query(alarm_date=None)),
sort_on=(('uid', 'ASC'),)
)
for alarm in alarm_list:
if not alarm.isEnabled():
continue
if alarm.sense():
message = portal.Base_translateString('You have one or more alarms with error.')
pending_error_message_list.append(
newTempBase(portal, "rss_entry",
uid=alarm.getUid(), # XXX Probably not a good idea
date=DateTime().earliestTime(),
link="%s/portal_alarms" % web_site_url,
title=message))
break
return pending_error_message_list
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment