Add custom content rules string substitutions

- Add content rules string substitutions for comment:
  - id
  - text
  - author email
  - author user name
  - author full name
This commit is contained in:
Alin Voinea
2014-04-18 16:36:06 +03:00
parent ab926d6a10
commit 13830715a7
3 changed files with 142 additions and 1 deletions
+12
View File
@@ -1,6 +1,7 @@
""" Custom discussion events
"""
from zope.interface import implements
from plone.app.discussion.interfaces import IComment
from plone.app.discussion.interfaces import IDiscussionEvent
from plone.app.discussion.interfaces import ICommentAddedEvent
from plone.app.discussion.interfaces import ICommentRemovedEvent
@@ -18,6 +19,17 @@ class DiscussionEvent(object):
for key, value in kwargs.items():
setattr(self, key, value)
# Add comment on session to easily define content-rules dynamic strings
sdm = getattr(context, 'session_data_manager', None)
session = sdm.getSessionData(create=True) if sdm else None
if session:
sessionComment = dict(
(field, getattr(comment, field, None)) for field in IComment
if not field.startswith('_')
)
session.set('comment', sessionComment)
class CommentAddedEvent(DiscussionEvent):
""" Event to be triggered when a Comment is added
"""