Commit 9fca9730 authored by Vincent Pelletier's avatar Vincent Pelletier

Make "notify" use "real" latest alarm report (it would be implicitely...

Make "notify" use "real" latest alarm report (it would be implicitely considered as incomplete since the alarm is still running).
Make sure consistent alarm report is used in "notify".


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@22467 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent e0ac27be
...@@ -434,7 +434,10 @@ class Alarm(XMLObject, PeriodicityMixin): ...@@ -434,7 +434,10 @@ class Alarm(XMLObject, PeriodicityMixin):
notification_mode = self.getAlarmNotificationMode() notification_mode = self.getAlarmNotificationMode()
if notification_mode == 'never': if notification_mode == 'never':
return return
if self.sense(): # Grab real latest result. Otherwise, we wuld chack n-1 execution as n is
# still considered running, and its result would be skipped.
active_process = self.getLastActiveProcess(include_active=True)
if self.sense(process=active_process):
prefix = 'ERROR' prefix = 'ERROR'
else: else:
if notification_mode != 'always': if notification_mode != 'always':
...@@ -444,7 +447,7 @@ class Alarm(XMLObject, PeriodicityMixin): ...@@ -444,7 +447,7 @@ class Alarm(XMLObject, PeriodicityMixin):
candidate_list = self.getDestinationValueList() candidate_list = self.getDestinationValueList()
if not candidate_list: if not candidate_list:
candidate_list = None candidate_list = None
result_list = [x for x in self.getLastActiveProcess().getResultList() if x is not None] result_list = [x for x in active_process.getResultList() if x is not None]
attachment_list = [] attachment_list = []
if len(result_list): if len(result_list):
def sort_result_list(a, b): def sort_result_list(a, b):
...@@ -475,12 +478,15 @@ Alarm URL: %s ...@@ -475,12 +478,15 @@ Alarm URL: %s
attachment_list=attachment_list) attachment_list=attachment_list)
security.declareProtected(Permissions.View, 'getLastActiveProcess') security.declareProtected(Permissions.View, 'getLastActiveProcess')
def getLastActiveProcess(self): def getLastActiveProcess(self, include_active=False):
""" """
This returns the last active process finished. So it will This returns the last active process finished. So it will
not returns the current one not returns the current one
""" """
limit = self.isActive() and 2 or 1 if include_active:
limit = 1
else:
limit = self.isActive() and 2 or 1
active_process_list = self.getPortalObject().portal_catalog( active_process_list = self.getPortalObject().portal_catalog(
portal_type='Active Process', limit=limit, portal_type='Active Process', limit=limit,
sort_on=(('creation_date', 'DESC'), ), sort_on=(('creation_date', 'DESC'), ),
......
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