Commit 7a708aab authored by Vincent Pelletier's avatar Vincent Pelletier

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.
parent 640d90a7
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
from compiler.consts import CO_VARKEYWORDS from compiler.consts import CO_VARKEYWORDS
from random import getrandbits from random import getrandbits
from Acquisition import aq_base
from DateTime import DateTime from DateTime import DateTime
from AccessControl import ClassSecurityInfo, Unauthorized from AccessControl import ClassSecurityInfo, Unauthorized
from AccessControl.SecurityManagement import getSecurityManager, \ from AccessControl.SecurityManagement import getSecurityManager, \
...@@ -327,9 +328,19 @@ class Alarm(XMLObject, PeriodicityMixin): ...@@ -327,9 +328,19 @@ class Alarm(XMLObject, PeriodicityMixin):
portal = self.getPortalObject() portal = self.getPortalObject()
notification_tool = portal.portal_notifications notification_tool = portal.portal_notifications
candidate_list = self.getDestinationValueList() candidate_list = []
if not candidate_list: domain_type_set = portal.getPortalDomainTypeList()
candidate_list = None 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] 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):
......
...@@ -511,6 +511,10 @@ ...@@ -511,6 +511,10 @@
<string>Person</string> <string>Person</string>
<string>Person</string> <string>Person</string>
</tuple> </tuple>
<tuple>
<string>Domain</string>
<string>Domain</string>
</tuple>
</list> </list>
</value> </value>
</item> </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