Changeset 1147
- Timestamp:
- 06/29/08 20:31:28
- Files:
-
- qPloneComments/branches/plone-3.0/utils.py (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
qPloneComments/branches/plone-3.0/utils.py
r1120 r1147 1 from Products.CMFPlone import MessageFactory 1 2 from Products.CMFCore.utils import getToolByName 3 2 4 # Get apropriate property from (propery_sheeet) configlet 3 5 def getProp(self, prop_name, marker=None): … … 15 17 self._p_changed = 1 16 18 self.reindexObject() 17 18 19 19 20 def setAnonymCommenting(context, allow=False): … … 71 72 72 73 def getParent(reply): 73 reply = reply.inReplyTo() 74 return reply.meta_type == 'Discussion Item' and getParent(reply) or reply 74 if reply.meta_type == 'Discussion Item': 75 reply = reply.inReplyTo() 76 return getParent(reply) 77 return reply 75 78 76 79 def getDIParent(reply): … … 96 99 subject = '' 97 100 if state == 'enable_approve_user_notification': 98 subject = 'Your comment on %s is now published'%context.Title()101 subject = 'Your comment on "%s" is now published' % getParent(context).Title() 99 102 if user_email: 100 103 template = 'notify_comment_template' … … 108 111 109 112 elif state == 'enable_rejected_user_notification': 110 subject = 'Your comment on %s was not approved.'%context.Title()113 subject = 'Your comment on "%s" was not approved' % getParent(context).Title() 111 114 if user_email: 112 115 template = 'rejected_comment_template' … … 121 124 elif state == 'enable_reply_user_notification': 122 125 template = 'reply_notify_template' 123 subject = 'Someone replied to your comment on %s'%context.Title()126 subject = 'Someone replied to your comment on "%s"' % getParent(context).Title() 124 127 di_parrent = getDIParent(reply) 125 128 if di_parrent: … … 144 147 'obj':reply_parent, 145 148 'organization_name':organization_name} 146 subject = '[%s] New comment added' %organization_name149 subject = '[%s] New comment added' % organization_name 147 150 else: 148 151 args = {} … … 156 159 'obj':reply_parent, 157 160 'organization_name':organization_name} 158 subject = '[%s] New comment awaits moderation' %organization_name161 subject = '[%s] New comment awaits moderation' % organization_name 159 162 else: 160 163 args = {} … … 172 175 From = admin_email) 173 176 174 175 HAS_MESSAGEFACTORY = True176 try:177 from Products.CMFPlone import MessageFactory178 except ImportError:179 HAS_MESSAGEFACTORY = False180 181 177 def getTranslFunction(context): 182 if HAS_MESSAGEFACTORY: 183 func = MessageFactory('plonecomments') 184 else: 185 func = lambda x:context.translate(x, domain='plonecomments') 186 return func 178 return MessageFactory('plonecomments') 187 179 188 180 def setStatusMsg(state, context, msg): 189 181 transl = getTranslFunction(context) 190 if HAS_MESSAGEFACTORY: 191 context.plone_utils.addPortalMessage(transl(msg)) 192 else: 193 state.set(portal_status_message=transl(msg)) 182 context.plone_utils.addPortalMessage(transl(msg))
