Commit 83b6802f authored by Vincent Pelletier's avatar Vincent Pelletier Committed by Jérome Perrin

Alarm: Add support for Predicates as notification targets.

And specifically, Domains (more portal types may be added to the relation
string field widget as needed).
Predicates get expanded to the list of documents they match.

backport of nexedi/erp5@7a708aab

Note: I had to change this commit a bit, it did not apply because our
erp5 is a bit old.

/reviewed-on https://lab.nexedi.com/nexedi/erp5-capago/merge_requests/29
parent e0c4f0fe
......@@ -28,6 +28,7 @@
##############################################################################
from compiler.consts import CO_VARKEYWORDS
from Acquisition import aq_base
from DateTime import DateTime
from AccessControl import ClassSecurityInfo, Unauthorized
from AccessControl.SecurityManagement import getSecurityManager, \
......@@ -300,10 +301,21 @@ class Alarm(XMLObject, PeriodicityMixin):
else:
prefix = 'INFO'
notification_tool = getToolByName(self, 'portal_notifications')
candidate_list = self.getDestinationValueList()
if not candidate_list:
candidate_list = None
portal = self.getPortalObject()
notification_tool = portal.portal_notifications
candidate_list = []
domain_type_set = ('Domain Generator', 'Domain')
for candidate_value in self.getDestinationValueList():
if candidate_value.getPortalType() in domain_type_set:
test = candidate_value.test
for recipient in portal.portal_catalog(
query=candidate_value.asQuery(),
):
recipient_value = recipient.getObject()
if test(recipient_value):
candidate_list.append(recipient_value)
else:
candidate_list.append(candidate_value)
result_list = [x for x in active_process.getResultList() if x is not None]
attachment_list = []
if len(result_list):
......
......@@ -511,6 +511,10 @@
<string>Person</string>
<string>Person</string>
</tuple>
<tuple>
<string>Domain</string>
<string>Domain</string>
</tuple>
</list>
</value>
</item>
......
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