Changeset 1147

Show
Ignore:
Timestamp:
06/29/08 20:31:28
Author:
deo
Message:

Fixed getParent to works also when called directly from the object with was commented. Made sure to always use the title from the commented object. Updated to always use MessageFactory?.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • qPloneComments/branches/plone-3.0/utils.py

    r1120 r1147  
     1from Products.CMFPlone import MessageFactory 
    12from Products.CMFCore.utils import getToolByName 
     3 
    24# Get apropriate property from (propery_sheeet) configlet 
    35def getProp(self, prop_name, marker=None): 
     
    1517    self._p_changed = 1 
    1618    self.reindexObject() 
    17  
    1819 
    1920def setAnonymCommenting(context, allow=False): 
     
    7172 
    7273    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 
    7578 
    7679    def getDIParent(reply): 
     
    9699    subject = '' 
    97100    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() 
    99102        if user_email: 
    100103            template = 'notify_comment_template' 
     
    108111 
    109112    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() 
    111114        if user_email: 
    112115            template = 'rejected_comment_template' 
     
    121124    elif state == 'enable_reply_user_notification': 
    122125        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() 
    124127        di_parrent = getDIParent(reply) 
    125128        if di_parrent: 
     
    144147                  'obj':reply_parent, 
    145148                  'organization_name':organization_name} 
    146             subject = '[%s] New comment added'%organization_name 
     149            subject = '[%s] New comment added' % organization_name 
    147150        else: 
    148151            args = {} 
     
    156159                  'obj':reply_parent, 
    157160                  'organization_name':organization_name} 
    158             subject = '[%s] New comment awaits moderation'%organization_name 
     161            subject = '[%s] New comment awaits moderation' % organization_name 
    159162        else: 
    160163            args = {} 
     
    172175                        From = admin_email) 
    173176 
    174  
    175 HAS_MESSAGEFACTORY = True 
    176 try: 
    177     from Products.CMFPlone import MessageFactory 
    178 except ImportError: 
    179     HAS_MESSAGEFACTORY = False 
    180  
    181177def 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') 
    187179 
    188180def setStatusMsg(state, context, msg): 
    189181    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))